Repository navigation
Enums
Frank edited this page Jan 27, 2026
·
3 revisions
Enums define named integer constants. Enum members are stored in a map, so values are accessed using dot syntax.
enum Color { Red, Green = 5, Blue }
print(Color.Red); // 0
print(Color.Green); // 5
print(Color.Blue); // 6- Members are integers.
- If a value is omitted, it auto-increments from the previous member (starting at
0). - Explicit values reset the increment counter for subsequent members.
enum Code { OK = 200, NotFound = 404, Gone }
// OK=200, NotFound=404, Gone=405- Enums are maps with an internal
__is_enumflag. - Enum values are integers and can be used in comparisons or switch cases.