## 8.7 If

if    GuardSeq1 ->        Body1;    ...;    GuardSeqN ->        BodyNend

The branches of an if-expression are scanned sequentially until a guard sequence GuardSeq that evaluates to true is found. Then the corresponding Body (sequence of expressions separated by ',') is evaluated.

The return value of Body is the return value of the if expression.

If no guard sequence is evaluated as true, an if_clause run-time error occurs. If necessary, the guard expression true can be used in the last branch, as that guard sequence is always true.

Example:

is_greater_than(X, Y) ->    if        X>Y ->            true;        true -> % works as an 'else' branch            false    end