Skip to main content
had to change param location after change view to public
Source Link
sola24
  • 1.2k
  • 4
  • 21

how about a different approach to the test, and what's returned, which might be easier.

check for length and return true/false

here I'm just passing in a string or "" as a logic tester

function isDefault(string calldatamemory _str) public pure returns (bool) {
    if(bytes(_str).length == 0) return true;
    return false;
}

how about a different approach to the test, and what's returned, which might be easier.

check for length and return true/false

here I'm just passing in a string or "" as a logic tester

function isDefault(string calldata _str) public pure returns (bool) {
    if(bytes(_str).length == 0) return true;
    return false;
}

how about a different approach to the test, and what's returned, which might be easier.

check for length and return true/false

here I'm just passing in a string or "" as a logic tester

function isDefault(string memory _str) public pure returns (bool) {
    if(bytes(_str).length == 0) return true;
    return false;
}
improved answer
Source Link
sola24
  • 1.2k
  • 4
  • 21

how about a different approach to the test, and what's returned, which might be easier.

check for length and return true/false

here I'm just passing in a string or "" as a logic tester

function isDefault(string calldata _str) externalpublic pure returns (bool) {
    if(bytes(_str).length == 0) return true;
    return false;
}

how about a different approach to the test and what's returned which might be easier.

check for length and return true/false

here I'm just passing in a string or "" as a logic tester

function isDefault(string calldata _str) external pure returns (bool) {
    if(bytes(_str).length == 0) return true;
    return false;
}

how about a different approach to the test, and what's returned, which might be easier.

check for length and return true/false

here I'm just passing in a string or "" as a logic tester

function isDefault(string calldata _str) public pure returns (bool) {
    if(bytes(_str).length == 0) return true;
    return false;
}
Source Link
sola24
  • 1.2k
  • 4
  • 21

how about a different approach to the test and what's returned which might be easier.

check for length and return true/false

here I'm just passing in a string or "" as a logic tester

function isDefault(string calldata _str) external pure returns (bool) {
    if(bytes(_str).length == 0) return true;
    return false;
}