If Statements

For simple branching, the if statement is provided for control flow.

An if statement requires a condition, which must be a boolean expression of type bool.

Parentheses are optional around the condition, but curly braces {} are strictly required around the body.

Example
if a {
    // executed if a is true
} else if (b) {
    // executed if a is false and b is true
}

An if statement can be followed by zero or more else if blocks and a single optional else block.

Example
if a {
    // executed if a is true
} else if b {
    // executed if a is false and b is true
} else if c {
    // executed if a and b are false and c is true
} else {
    // executed if all conditions are false
}

The else block must come last.