switch

    1. 1/2 test "switch simple"...OK
    2. 2/2 test "switch inside function"...OK
    3. All tests passed.

    switch can be used to capture the field values of a . Modifications to the field values can be done by placing a * before the capture variable name, turning it into a pointer.

    1. 1/1 test "switch on tagged union"...OK
    2. All tests passed.

    See also:

    test.zig

    1. switch (color) {
    2. ^

    Switching with Enum Literals

    test.zig

    1. $ zig test test.zig
    2. 1/1 test "enum literals with switch"...OK