Enumerations: Difference between revisions

Content added Content deleted
(Rename Perl 6 -> Raku, alphabetize, minor clean-up)
(Added Wren)
Line 1,739: Line 1,739:
cherry = 2
cherry = 2
End Enum</lang>
End Enum</lang>

=={{header|Wren}}==
Wren doesn't support either enums or constants as such but a common way to indicate that a variable should not be mutated is to give it an upper case name and to group related variables together.

The only way to give such a variable a value without setting it explicitly is to add one to the previous such variable which (in effect) is what a C-style enum does. If you declare a variable in Wren without giving it a value, then it is set to the special value ''null'' which is no help here.
<lang ecmascript>var APPLE = 1
var ORANGE = 2
var PEAR = 3

var CHERRY = 4
var BANANA = CHERRY + 1
var GRAPE = BANANA + 1

System.print([APPLE, ORANGE, PEAR, CHERRY, BANANA, GRAPE])</lang>

{{out}}
<pre>
[1, 2, 3, 4, 5, 6]
</pre>


=={{header|XPL0}}==
=={{header|XPL0}}==