Skip to main content

while

The while loop is used to execute a block of code while a condition is truthy.

let x = 0
while x < 5 {
Transmission { %(x) }
x += 1
}
// Outputs 0, 1, 2, 3, 4

Expressions

When while is used in an expression, the break statement determines the resulting value of the expression. If the loop exists without a break, the resulting value will be undefined.

let a = while Tick < 10s {
if that.Pos.X > 100 {
break 100
}
}
// a is either `100` or `undefined` depending on whether the condition was met before the loop ended