Update 'Enum Type Definitions'

Sasha Koshka 2022-08-30 05:54:26 +00:00
parent 4a539490bc
commit 11166ea9fd

30
Enum-Type-Definitions.md Normal file

@ -0,0 +1,30 @@
# Syntax
```
enum ro Weekday:Int
sunday
monday
tuesday
wednesday
thursday
friday
enum ro NamedColor:U32
red 0xFF0000
green 0x00FF00
blue 0x0000FF
```
Each line under an enum represents a member and is composed of a name, and an optional initialization value.
Enum members are accessed similarly to object members:
```
set day:Weekday Weekday.thursday
```
# Semantics
Enums "enumerate" a pre-existing type, most likely an Int.
Enum members can have explicitly defined values, but if they don't, their value
is just incremented up from zero. The order in which members are listed in matters.