WHEN

From HEWIKI
Jump to: navigation, search
This is the conditional branching statement. For the command to identify a node's classes, see WHERE.

when {expression}
  is {literal}
      statements
  .
  is {literal}
      statements
  .
  default      // optional
     statements
  .
.

Description

This a conditional branching statement, that allows the execution of different sections of code depending on the value of a particular variable.

The expression is evaluated, and then the engine checks for the first literal to match it, in order to execute those statements. If not literal is matched, then execution drops to an optional default section.

Example

when x 
  is 1
    println("x is 1")
  .
  is 2
    println("x is 2")
  .
  default
    println("x is neither 1 nor 2")
  .
.
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox