rhai/doc/src/language/while.md
2020-07-06 16:20:03 +08:00

427 B

while Loop

{{#include ../links.md}}

while loops follow C syntax.

Like C, continue can be used to skip to the next iteration, by-passing all following statements; break can be used to break out of the loop unconditionally.

let x = 10;

while x > 0 {
    x -= 1;
    if x < 6 { continue; }  // skip to the next iteration
    print(x);
    if x == 5 { break; }    // break out of while loop
}