Chapter 5. Flow control

If statements

An if statement is used to execute statements only when a specified condition is true.

if condition then statement
if condition  /* optional "then" here */
    statements
end

An if statement may have an else clause, which is executed when the condition is false.

if condition then statement else statement
if condition
    statements
else
    statements
end

The else clause may itself be an if statement, taking this form:

if condition
    statements
else if condition
    statements
/* ... */
else
    statements
end