Posted on

Who can tell me how to read array positions using enum

Image description
I'm newbie, Write long conversion code each time.
What's the best way to do it?

Top comments (2)

kristoff profile image
Loris Cro

Hi @pixeller, Zig NEWS is a blogging platform not meant to be used like a forum (although I know that other Forem instances, like dev.to, do allow this kind of usage). In the future I would recommend you check out one of the other Zig communities for help.

In particular checkout https{//ziggit.dev if you want a forum and discord.gg/zig if you want real-time chat (#zig-help in there is very active).

For this specific question you might be interested in std.EnumArray.

pixeller profile image
const n: u32 = @intCast(@intFromEnum(k) & 511);
Enter fullscreen mode Exit fullscreen mode

Uh, okay.
I've solved it, Thank you.