Curriculum Basics while and for exercise 9 · freeform
while and for
About this theme
Zig has while (cond) { ... } for condition-driven loops and for (slice) |item| { ... } for iteration. The C-style three-clause for (init; cond; step) is gone — its replacement is while (cond) : (step) { ... } (note the colon-continuation syntax for the step expression). The TS for...of reflex maps directly to Zig's for (...) |item|.