Course of Raku / Essentials / Positional data types / Interpolating arrays

Quiz — Interpolating arrays

Given the following array:

my @arr = 10, 9, 8, 3, 2, 1;

Complete the below programs to get the requested output.

1

Print the third element (the item with index 2).

[2] say "The third element is @arr␣␣";

2

Print all elements (without indexing all of them explicitly).

arr[] say "This array contains: @␣␣␣␣."; The output is ”This array contains: 10 9 8 3 2 1.“

3

Print the size of the array (by calling the elems method).

{@arr.elems} say "There are ␣␣␣␣␣␣␣␣ elements."; Curly braces required to embed Raku code into a Raku string.

Course navigation

Positional data types / The @*ARGS array   |   Positional data types / Lists


💪 Or jump directly to the exercises to this section.

Translations of this page: EnglishDeutschEspañolItalianoLatviešuNederlandsБългарскиРусскийУкраїнська