mirror of
https://github.com/ziglang/zig.git
synced 2024-11-26 15:12:31 +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>
27 lines
509 B
Zig
27 lines
509 B
Zig
const std = @import("std");
|
|
|
|
test "switch continue" {
|
|
sw: switch (@as(i32, 5)) {
|
|
5 => continue :sw 4,
|
|
|
|
// `continue` can occur multiple times within a single switch prong.
|
|
2...4 => |v| {
|
|
if (v > 3) {
|
|
continue :sw 2;
|
|
} else if (v == 3) {
|
|
|
|
// `break` can target labeled loops.
|
|
break :sw;
|
|
}
|
|
|
|
continue :sw 1;
|
|
},
|
|
|
|
1 => return,
|
|
|
|
else => unreachable,
|
|
}
|
|
}
|
|
|
|
// test
|