Skip to main content
Version: Zig 0.13.0

Labelled Loops

Loops can be given labels, allowing you to break and continue to outer loops.

test "nested continue" {
var count: usize = 0;
outer: for ([_]i32{ 1, 2, 3, 4, 5, 6, 7, 8 }) |_| {
for ([_]i32{ 1, 2, 3, 4, 5 }) |_| {
count += 1;
continue :outer;
}
}
try expect(count == 8);
}