While Expression

while-expression ::= 'while' expression block-expression while-expression-else?
while-expression-else ::= 'else' block-expression

Evaluates the first block-expression (the loop body) repeatedly until the expression (the condition) no longer tests as truthy. The condition is evaluated at the beginning of every iteration. If no iterations run and a while-expression-else is present, the second block-expression (the else body) is evaluated once.

The whole expression results in one of the following values, in order:

  1. The result of any break as expression within the loop body.

  2. The result of the loop body, if at least one iteration completes.

  3. The result of the else body, if a while-expression-else is present.

Last updated

Copyright © Vezel Contributors