The conditional statement has the following syntax:
IF ⟨boolean expression⟩ THEN ⟨statement⟩
The boolean expression is evaluated. If this is true, the first ⟨statement⟩ is executed. If it is false, the second is.
Note the use of the group statement.
Conditional statements associate to the right; i.e.,
is equivalent to:
In addition, the construction
If the value of the conditional statement is of primary interest, it is often called a conditional expression instead. Its value is the value of whichever statement was executed. (If the executed statement has no value, the conditional expression has no value or the value 0, depending on how it is used.)
If the value is of no concern, the ELSE clause may be omitted if no action is required in the false case.
Note: As explained in Section 3.3, if a scalar or numerical expression is used in place of the boolean expression – for example, a variable is written there – the true alternative is followed unless the expression has the value 0.