Skip to content

Instantly share code, notes, and snippets.

@PetarKirov
Created September 23, 2020 19:11
Show Gist options
  • Save PetarKirov/ea6e3d04d1cfd5e4c939ffed1a8141ef to your computer and use it in GitHub Desktop.
Save PetarKirov/ea6e3d04d1cfd5e4c939ffed1a8141ef to your computer and use it in GitHub Desktop.
Enum associative arrays
void main() {}
enum string[ubyte] valueTypes = [
0x7F: "i32",
0x7E: "i64",
0x7D: "f32",
0x7C: "f64"
];
pure unittest
{
auto aa1 = valueTypes;
auto aa2 = valueTypes;
assert(aa1 !is aa2); // aa1 and aa2 *point to different* objects
assert(aa1 == aa2); // those distinct objects *are equal* (contain the same key-value mapping)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment