rhai/doc/src/language/while.md

21 lines
427 B
Markdown
Raw Normal View History

2020-06-20 06:06:17 +02:00
`while` Loop
============
{{#include ../links.md}}
2020-06-21 18:03:45 +02:00
`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.
2020-06-20 06:06:17 +02:00
```rust
let x = 10;
while x > 0 {
2020-07-06 10:20:03 +02:00
x -= 1;
2020-06-20 06:06:17 +02:00
if x < 6 { continue; } // skip to the next iteration
print(x);
if x == 5 { break; } // break out of while loop
}
```