If statements

If statements are used to control the flow of logic in a script. It is important to note that they return a value, and thus can be used as the return value of a function.

Lambda Calculus representation

@bxy.b x y

Usage

if ([condition]) { [multiline expression] } else { [multiline expression] }

Alternatively, either multiline expression can be replaced by a single expression.

if ([condition]) [value] else { [multiline expression] }

if ([condition]) { [multiline expression] } else [value]

if ([condition]) [value] else [value]

elif

Elif (short for else if) can be used to create if statements with more than one condition.

This means that

if (condition1) value1 else { if (condition2) value2 else value3 }

can be shortened to

if (condition1) value1 elif (condition2) value2 else value3

Example

See also