ETHEREUM SMART CONTRACTS DEVELOPMENT
Solidity Fundamentals
Control Structures
Most of control structures that we are familiar from Javascript, C or Python are also exist in Solidity. There is if
, else
, while
, do
, for
, break
, continue
, return
with the common semantics from above mentioned languages. Let’s look at an example, and investigate each one of them:
While writing smart contracts, we may need to perform a specific action multiple times. Therefore we use loops to fulfill this need.
Solidity also supports exception handling in the form of
try/catch
statements, but only for external function calls and contract creation call. We will work on these topics in upcoming sections.
Next, we will be working on error handling — assert
, require
, revert
and try/catch
. Thanks for reading.