Hacker News new | ask | show | jobs
by andolanra 4139 days ago
I see this used a lot with enums to make a kind of 'homogeneous struct' where all the members have the same type:

    enum fields = { x, y, z };
    int point[] = {
      [x] = 1,
      [y] = 2,
      [z] = 3
    };
This is used pretty extensively in the QEMU codebase, which is where I first learned it.
1 comments

How does this even work?!?!
x, y, z being enum values, are constants.