The if decision control

Solidity provides conditional code execution with the help of the if...else instructions. The general structure of if...else is as follows:

if (this condition/expression is true) {   Execute the instructions here} else if (this condition/expression is true) {   Execute the instructions here} else {   Execute the instructions here}

if and if-else  are keywords in Solidity and they inform the compiler that they contain a decision control condition, for example, if (a > 10). Here, if contains a condition that can evaluate to either true or false.  If a > 10 evaluates to true then the code instructions that follow in the pair of double-brackets ({) and (}) should be executed.

else is also a keyword that provides an alternate ...

Get Solidity Programming Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.