Skip to main content

Boolean.if_then_else

if_then_elseon_trueon_false

Group: Logical

Documentation

The if-then-else control flow operator that executes one of two branches based on a conditional.

Both of the arguments to this method are lazy, meaning that they will only be evaluated if they are needed (based on the condition).

Arguments

  • on_true: The computation to evaluate if this evaluates to True.
  • on_false: The computation to evaluate if this evaluates to False.

Examples

Telling the user if a number 27 is divisible by three.

      if (27 % 3) == 0 then IO.println "Yes" else IO.println "No"