4: Control Structures
Conditional Statements
function isEven(uint256 x) public pure returns (bool) {
if (x % 2 == 0) {
return true;
} else {
return false;
}
}function isPositive(uint256 x) public pure returns (bool) {
if (x > 0) {
return true;
} else if (x == 0) {
return false;
} else {
revert("Number is negative");
}
}Loops
Control Structures with Modifiers
Last updated