Enum is the base class for enum classes defined using the enum
keyword. An enum models a fixed range of discrete values. Each value has an Int ordinal and a Str name.
Every enum class implicitly has the following slots auto-generated by the compiler:
- a static const field for each name in the enum's range.
- a static field called "values" which contains the list of discrete values indexed by ordinal.
- a static method called "fromStr" which maps an enum name to an enum instance
See docLang::Enums for details.
Slots
- compareSource
-
Overrides sys::Obj.compare
Compare based on ordinal value.
- doFromStrSource
-
static protected Enum? doFromStr(Type t, Str name, Bool checked)
Protected fromStr implementation - for compiler use only. A public static fromStr method is always auto-generated by the compiler for each enum.
- equalsSource
-
override Bool equals(Obj? obj)
Overrides sys::Obj.equals
Enums are only equal if same instance using ===.
- makeSource
-
new make(Int ordinal, Str name)
Protected constructor - for compiler use only.
- nameSource
-
Str name()
Get the programatic name for this enum.
- ordinalSource
-
Int ordinal()
Return ordinal value which is a zero based index into values.
- toStrSource
-
override Str toStr()
Overrides sys::Obj.toStr
Always returns name().