Course of Raku / Advanced / Containers / Contexts 🆕 / Numeric, string, and Boolean context

Quiz — Contexts

What does the following program print?

my @a = 10, 20, 30;
say +@a;
060
13
010
010 20 30

The + prefix forces numeric context. For an array, the numeric value is its number of elements, so +@a is 3, not the sum. Use ~ for string context (10 20 30) or [+] to actually add the elements.

Course navigation

Numeric, string, and Boolean context   |   Item and list context