Course of Raku / Advanced / Subroutines / Calling with a colon 🆕
Quiz — The colon call
What does the following program print?
say 'programming'.substr: 0, 3;| 1 | pro |
| 0 | program |
| 0 | ing |
| 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.