Most of the control structures from other languages are also supported in solidity. In this recipe, you will learn about supported control structures in solidity, along with examples. The semantics are very similar to C or JavaScript.
Control structures in Solidity
How to do it...
- If-else condition statements are used to perform different actions based on different conditions. Create a function, isValid, which returns true for input values greater than 10 and returns false otherwise:
pragma solidity ^0.4.23;
contract test {
function isValid(uint input) public pure
returns (bool) {
if (input > 10) {
return true;
} else {
return false;
}
}
}
Solidity doesn't support...