Course of Raku / Advanced / More about built-in types / Enumerations 🆕 / Defining an enum

Quiz — Enumerations

What does the following program print?

enum Colour <red green blue>;
say green + blue;
13
0greenblue
0(green blue)
0an error

Each constant stands for a number, assigned from zero in the order listed: red is 0, green is 1, blue is 2. In an arithmetic context the constants act as those numbers, so green + blue is 1 + 2, which is 3.

Course navigation

Defining an enum   |   Values and keys