while: repeating while a condition is true

Syntax and values

let count = 3

while count > 0:
    say count
    set count = count - 1

The condition is evaluated before each iteration and must be Boolean. Each iteration body has a fresh child scope. Use set on an outer variable to retain changes between iterations.

There is no break or continue statement. Structure the condition or use a function return when appropriate. Long-running cooperative loops should call a positive wait so they remain responsive and receive a fresh instruction budget slice.

Example

# language: en
let count = 3
while count > 0:
    say count
    set count = count - 1

Syntax and values · Built-ins · Programming guides