mirror of
https://github.com/ziglang/zig.git
synced 2024-11-26 23:22:44 +00:00
cf69154332
Add langref docs for labeled switch This feature was proposed in #8220, and implemented in #21257. Co-authored-by: Andrew Kelley <andrew@ziglang.org>
29 lines
564 B
Zig
29 lines
564 B
Zig
const std = @import("std");
|
|
|
|
test "switch continue, equivalent loop" {
|
|
var sw: i32 = 5;
|
|
while (true) {
|
|
switch (sw) {
|
|
5 => {
|
|
sw = 4;
|
|
continue;
|
|
},
|
|
2...4 => |v| {
|
|
if (v > 3) {
|
|
sw = 2;
|
|
continue;
|
|
} else if (v == 3) {
|
|
break;
|
|
}
|
|
|
|
sw = 1;
|
|
continue;
|
|
},
|
|
1 => return,
|
|
else => unreachable,
|
|
}
|
|
}
|
|
}
|
|
|
|
// test
|