2023-07-18 13:51:12 -07:00
|
|
|
in Org:RosettaCode
|
|
|
|
|
type Fruits
|
|
|
|
|
enum
|
|
|
|
|
int APPLE, BANANA, CHERRY
|
|
|
|
|
end
|
|
|
|
|
type ExplicitFruits
|
|
|
|
|
enum
|
2025-02-27 18:35:13 -05:00
|
|
|
int APPLE ← 10
|
|
|
|
|
int BANANA ← 20
|
|
|
|
|
int CHERRY ← 1
|
2023-07-18 13:51:12 -07:00
|
|
|
end
|
|
|
|
|
type Main
|
|
|
|
|
for each generic enumeration in generic[Fruits, ExplicitFruits]
|
2025-02-27 18:35:13 -05:00
|
|
|
writeLine("[", Generic.name(enumeration), "]")
|
2023-07-18 13:51:12 -07:00
|
|
|
writeLine("getting an object with value = 1:")
|
|
|
|
|
writeLine(:enumeration.byValue(1))
|
|
|
|
|
writeLine("iterating over the items:")
|
|
|
|
|
for each var fruit in :enumeration
|
|
|
|
|
writeLine(fruit)
|
|
|
|
|
end
|
|
|
|
|
writeLine()
|
|
|
|
|
end
|