forked from boo-lang/boo
-
Notifications
You must be signed in to change notification settings - Fork 0
Language guide: enums
scottstephens edited this page Jul 17, 2012
·
4 revisions
The keyword enum introduces an enumerated type, a set of name to integer value associations.
enum Python:
Eric
John
TerryG
TerryJ
Graham
Michael
which is equivalent to:
enum Python:
Eric = 0
John = 1
TerryG = 2
TerryJ = 3
Graham = 4
Michael = 5
Extracting the integer value of a enum is just a matter of casting it to an int:
print((Python.TerryG cast int)*2) # prints 4
It's possible to define partial enums:
partial enum E:
Foo
partial enum E:
Bar
for value in System.Enum.GetValues(E):
print value, "=", value cast int