Course of Raku / Advanced / Containers / Contexts 🆕 / Exercises / Force a number
Solution: Force a number
Here is a possible solution to the task.
Code
my @a = 1, 2, 3;
say +@a;🦋 You can find the source code in the file force-a-number.raku.
Output
3Comments
The
+prefix forces numeric context.In numeric context, an array becomes its element count, so the result is
3.