Solidity

Solidity Control Structures

Solidity Control Structures Main Tips

  • In Solidity, much like in JavaScript, functions can take input in the form of parameters.
  • An arbitrary number of the parameters may also be returned as output.

Solidity Control Structures

The majority of the JavaScript control structures are provided in Solidity as well, with the exception of goto and switch. Solidity provides these control structures:

  • if
  • while
  • else
  • for
  • do
  • continue
  • return
  • break
  • ? :

All with the normal semantics that are known from JavaScript or C.

Parentheses, for conditionals, must not be omitted, however, curly braces are possible to omit around bodies that are single-statement.

Keep in mind that no type conversion applies to non-boolean types to boolean ones unlike in C and JavaScript, so if (1) { … } would not be valid Solidity.

Returning Multiple Values

Whenever a function possesses multiple output parameters, return (v0, v1, …, vn) may return more than one value. The component amount has to be the same as the number of parameters used for output.

Read previous post:
Solidity Input and Output Parameters

Solidity Input and Output Parameters Main Tips In Solidity, much like in JavaScript, functions can take input in the form...

Close