Next: Unary Minus, Previous: Value_Type, Up: Expressions
if
Expression
An if
expression has the following form:
if condition1 then expression1 elseif condition2 then expression2 else expression3 end if
The elseif
part may be repeated unrestrictedly (including zero times).
First, condition1 is evaluated. If it is satisfied, the
expression expression1 is evaluated and yields the value of the
if
expression.
If condition1 is not satisfied, each condition following an
elseif
keyword is evaluated in turn, until a condition is found
that is satisfied. The expression that follows this condition will be
evaluated and yields the value of the if
expression.
If the if
condition and elseif
conditions all fail, the
expression expression3 will be evaluated and yields the value of
the if
expression.
The if
after the end
may be omitted.