Tutorial by Topics: enumerations

Approach with sealed trait and case objects is preferred because Scala enumeration has a few problems: Enumerations have the same type after erasure. Compiler doesn't complain about “Match is not exhaustive", if case is missed it will fail in runtime scala.MatchError: def isWeekendWith...
In computer programming, an enumerated type (also called enumeration or enum [..]) is a data type consisting of a set of named values called elements, members or enumerators of the type. The enumerator names are usually identifiers that behave as constants in the language. A variable that h...
Enumerations consist of the enum keyword and an optional identifier followed by an enumerator-list enclosed by braces. An identifier is of type int. The enumerator-list has at least one enumerator element. An enumerator may optionally be "assigned" a constant expression of type int. ...

Page 1 of 1