Learning Zig from the official language reference.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
zig-langref/labelled_for.zig

27 lines
576 B

const std = @import("std");
const debug = std.debug;
const testing = std.testing;
test "nested break" {
var count: usize = 0;
outer: for ([_]u32{ 1, 2, 3, 4, 5 }) |_| {
for ([_]u32{ 1, 2, 3, 4, 5 }) |_| {
count += 1;
break :outer;
}
}
testing.expectEqual(count, 1);
}
test "nested continue" {
var count: usize = 0;
outer: for ([_]u32{ 1, 2, 3, 4, 5 }) |_| {
for ([_]u32{ 1, 2, 3, 4, 5 }) |_| {
count += 1;
continue :outer;
}
}
testing.expectEqual(count, 5);
}