Update 'Enum Type Definitions'

Sasha Koshka 2022-08-24 16:30:55 +00:00
parent e84e10b439
commit c8f91f394e
1 changed files with 17 additions and 5 deletions

@ -1,4 +1,6 @@
Enums "enumerate" a pre-existing type, most likely an Int.
# Syntax
```
enum ro Weekday:Int
@ -8,13 +10,23 @@ enum ro Weekday:Int
wednesday
thursday
friday
enum ro NamedColor:U32
red 0xFF0000
green 0x00FF00
blue 0x0000FF
```
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.
Each line under an enum represents a member and is composed of a name, and an optional initialization value.
Enum members are accessed similar to object members:
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.