Enumeration is the data type that is used to define, for example, possible values of some concept. For example, traffic light colors take three values:
enum TrafficLight <red yellow green>;
The names of the values become known to Perl 6 and thus you may use them directly in a program, for example:
say red;
This code prints the name of the value:
red
In this example, the actual values of the red, yellow, and green names are not important for us but Perl 6 assigns increasing integer values to them.
say red + yellow + green; # 6
This program is equivalent to say 0 + 1 + 2.
When the values are important, then you can specify them explicitly, as we do in the next example:
enum Floors ( garage => -1, ground-floor => 0, first => 1, second => 2);
We will see one of the examples of the enumeration in the definition of the Boolean type in Perl 6 in the next section.