Course of Raku / Advanced / Subroutines / The Whatever star 🆕

Quiz — The Whatever star

What does the following program print?

my @a = 5, 6, 7, 8, 9;
say @a[*-2];
18
07
09
03

In a subscript, the bare * stands for the number of elements — here 5. So *-2 is index 3, and the element at index 3 (counting from zero) is 8.

Course navigation

Solution: An open-ended range   |   Calling with a colon 🆕