Skip to content

If & else

Giorgio Garofalo edited this page Jan 18, 2022 · 7 revisions

Pikt handles conditions the traditional way via if / else / else if statements. Syntax:

if <condition> <block>
else if <condition> <block>
else <block>

Where <condition> can be any kind of expression. If it is a boolean expression, the condition is true only if the boolean is true. Otherwise the condition is true if the given expression is not null, but we will learn about nullable values later.

<block> contains the code to be executed if the condition is satisfied.
It can be either a single action, such as a function call or a variable update, or a more complex block. In that case, it has to be surrounded by lambda.open and lambda.close , as shown in the for-each guide.

WIP...

Clone this wiki locally