Created
September 23, 2020 19:11
-
-
Save PetarKirov/ea6e3d04d1cfd5e4c939ffed1a8141ef to your computer and use it in GitHub Desktop.
Enum associative arrays
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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