Enumerations: Difference between revisions

(Added DWScript)
(→‎{{header|Groovy}}: new solution)
Line 341:
)</lang>
Constants in Go are not typed they way variables are, and so constants defined with iota do not actually represent an enumeration data type. Go does not have an enumeration data type.
 
=={{header|Groovy}}==
Enumerations:
<lang groovy>enum fruit1 { apple, banana, cherry }
 
enum fruit2 {
apple(1), banana(2), cherry(3);
def value
fruit2(val) {value = val}
String toString() { super.toString() + "(${value})" }
}
 
println fruit1.values()
println fruit2.values()</lang>
 
Output:
<pre>[apple, banana, cherry]
[apple(1), banana(2), cherry(3)]</pre>
 
=={{header|Haskell}}==
Anonymous user