Course of Raku / Advanced / More about built-in types / Enumerations 🆕 / Values and keys
Quiz — Enum values
What does the following program print?
enum Day (Mon => 1, Tue => 2);
say Tue.key;| 1 | Tue |
| 0 | 2 |
| 0 | 1 |
| 0 | Mon |
.value gives the number behind a constant, but
.key gives its name as a string. So
Tue.key is Tue, regardless of the number
2 that was assigned to it.