Page:
Enum Type Definitions
Pages
Arguments
Blind Type Definitions
Body
Control Flow
Data
Enum Type Definitions
File Structure
Functions and Methods
General Syntax
Guidelines
Home
Identifiers
Initialization
Interface Definitions
Metadata
Modules
Object Type Definitions
Permissions
Phrases
Return Direction
Tokens
Variable Definition and Type Notation
Clone
2
Enum Type Definitions
Sasha Koshka edited this page 2022-08-24 16:30:55 +00:00
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.