On this page:
2.1.10.1 When Statements
2.1.10.2 Assignment Statements
2.1.10.3 Binop Expression “Statements”
2.1.10 Statements

There are just a few forms that can only appear as statements in blocks that aren’t declarations:

‹stmt›: ‹when-stmt› | ‹assign-stmt› | ‹binop-expr›

2.1.10.1 When Statements

A when expression has a single test condition with a corresponding block.

‹when-stmt›: when ‹binop-expr› [block] : ‹block› end

For example:

when x == 42: print("answer") end

If the test condition is true, the block is evaluated. If the test condition is false, nothing is done, and nothing is returned.

2.1.10.2 Assignment Statements

Assignment statements have a name on the left, and an expression on the right of :=:

‹assign-stmt›: NAME := ‹binop-expr›

If NAME is not declared in the same or an outer scope of the assignment expression with a var declaration, the program fails with a static error.

At runtime, an assignment expression changes the value of the assignable variable NAME to the result of the right-hand side expression.

2.1.10.3 Binop Expression “Statements”

The ‹binop-expr› production is included in ‹stmt› because any expression can appear where a statement can (subject to restrictions from well-formedness checking).