-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_test.zr
33 lines (25 loc) · 866 Bytes
/
_test.zr
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// This:
/*enum Animals {
Dog,
Cat,
Fox,
}*/
// Same as:
let Animals = .{
Dog: null "__base_enum;__enum_variant=\"7d500443-ffa5-4383-bb65-4f5ed5f154c3\"",
Cat: null "__base_enum;__enum_variant=\"b3cb1678-5c59-4218-8ace-bb02c24ea989\"",
Fox: null "__base_enum;__enum_variant=\"fd41c2c6-4966-42fb-a7c4-ddb7e3bd6e60\"",
};
// This would work by the call handler function checking if Animals.Dog contains the "__base_enum" tag
// This would mean you can't do it with derived values like dog("John")
let dog = Animals.Dog("John");
// Dog internally looks like:
// Value: "John"
// Tags: { __enum_variant:"7d500443-ffa5-4383-bb65-4f5ed5f154c3" }
// This:
if dog == Animals.Dog {
}
// Same as:
if dog.__tags.__enum_variant == Animals.Dog.__tags.__enum_variant {
}
// The above would work by checking if it has an __enum_variant tag available