switch
1/2 test "switch simple"...OK
2/2 test "switch inside function"...OK
All 2 tests passed.
switch
can be used to capture the field values of a Tagged union. Modifications to the field values can be done by placing a *
before the capture variable name, turning it into a pointer.
$ zig test test.zig
All 1 tests passed.
See also:
test.zig
$ zig test test.zig
./docgen_tmp/test.zig:9:5: error: enumeration value 'Color.Off' not handled in switch
./docgen_tmp/test.zig:7:29: note: referenced here
test "exhaustive switching" {
^
Switching with Enum Literals
test.zig
$ zig test test.zig
1/1 test "enum literals with switch"...OK