
上QQ阅读APP看书,第一时间看更新
Enum
The enum data type will have a named set of values. We use enumerators to give user-friendly names to constants that identify certain values:
enum Day {Mon, Tue, Wed, Thu, Fri, Sat, Sun}; var firstDay: Day = Day.Mon;
Here, we have the Day enum variable, which holds a series of values that represent each day of the week. The second statement shows how to access a particular enum value in a day and assign it to another variable.