Skip to main content
Tour of Lux · chapter 4 of 8

Control flow

if/else, pattern matching, and loops.

match is an expression. Arms take literals, ranges like 1..10, guards with if, and a _ catch-all. Bound names are usable inside the arm.
for iterates ranges (1..=10 is inclusive) and lists; while, break, and continue do what they say. The receipt below makes loop cost visible — try changing 1..=10 to 1..=1000 and watch the steps grow.