while
Repeats as long as the condition is true.
Syntax
while condition ... end
Description
If the number of iterations is not known beforehand, while is used. At the top level, you must write global when updating an external variable.
Example
Loading editor…
Expected output
0 1 2
When to use?
Conditional repetition.
Common mistakes
- ⚠️ Forgetting global either causes an infinite loop or a warning/incorrect result.