How to index an enum structure?

i think you’re looking for @intToEnum

test "asdf" {
    const FUNC = enum {
        none,
        F1,
        F2,
        F3,
        F4,
        F5,
    };

    var func = @intToEnum(FUNC, 1);
    std.debug.print("got enum \"{}\"\n", .{func}); // "F1"
}

output:

Test [1/1] test.asdf... got enum "main.test.asdf.FUNC.F1"
1 Like