break and continue
break and continue alter the flow of a loop:
breakexits the innermost loop immediately.continueskips the rest of the current iteration and moves on — re-evaluating the condition in awhile, or advancing to the next element in afor.
rux
while true {
let input = ReadLine();
if input == "quit" { break; } // leave the loop
if input == "" { continue; } // skip blank lines
Process(input);
}Targeting an Outer Loop
By default both act on the innermost enclosing loop. To affect an outer loop instead, give that loop a label and name it: break label or continue label (see Labels):
rux
outer: for row in rows {
for cell in row {
if cell == target { break outer; } // exit both loops
}
}