If/Unless-Statement


if expression { } else { }
if expression { }
if (expression) statement;
statement if expression;

If the conditional expression is true (non-zero), execute the first block, otherwise execute the second. The else part is optional. The keyword unless may be substituted to mean "if not."


if n == 0 {
   print("The number is zero.");
}
else if n == 1 {
   print("The number is one.");
}
else {
   print("The number isn't zero or one.");
}

Switch-Statement


switch expression {
case value:
               statements;
case value, value:
               statements;
default:
               statements;
}

The switch statement evaluates an expression and then selects a block of code with an equal constant value listed. If no value matches, then the default block is executed, or if absent, no blocks are executed.

The parenthesis surrounding the expression are optional.