Course of Raku / Advanced / Subroutines / Calling with a colon 🆕

Quiz — The colon call

What does the following program print?

say 'programming'.substr: 0, 3;
1pro
0program
0ing
0(0 3)

The colon consumes the whole rest of the statement as the argument list, so substr: 0, 3 is the same as substr(0, 3) — both arguments are passed. Starting at index 0 and taking 3 characters gives pro.

Course navigation

Solution: Sort with a colon   |   Multiple dispatch