Loops
Looping.
Just like other programming languages, Stof has loops: while, for, & loop.
While
#[main]
fn main() {
let count = 100;
while (count > 0) {
count -= 1;
}
}Loop
A "loop" is a "while (true)" loop.
#[main]
fn main() {
let count = 100;
loop {
count -= 1;
if (count <= 0) break;
}
}For
For loops can take values by reference as well, with the "&" operator.
Tagging
All loops can be tagged for greater control and readability (while, loop, & for). Once a loop is tagged, both "continue ^tag" and "break ^tag" will control that loop, regardless of nested loop structure.
Last updated