Course of Raku / Essentials / More about types / Positional data types / Nested arrays

Quiz — Nested arrays

An array of arrays keeps the temperatures measured on four days, three readings per day:

my @data =
    [1.2, 2.3, 3.4],
    [4.5, 5.6, 6.7],
    [5.6, 6.7, 7.8],
    [6.7, 7.8, 8.9];

Single elements

What do you expect to see in the output at each of the following lines of code?

5.6say @data[1][1]; # ␣␣␣
1.2say @data[0][0]; # ␣␣␣
7.8say @data[2][2]; # ␣␣␣

Comparing

Select the correct Boolean result of the following comparisons.

False@data[0][0] == @data[2][2] is  (: False, True :)
True@data[1][1] == @data[2][0] is  (: False, True :)

Lengths

What value do the following calls of the elems method return?

4@data.elems —  (: 1, 2, 3, 4, 5 :)
3@data[0].elems —  (: 1, 2, 3, 4, 5 :)
3@data[1].elems —  (: 1, 2, 3, 4, 5 :) 
3@data[2].elems —  (: 1, 2, 3, 4, 5 :)

Course navigation

Nested arrays   |   The @*ARGS array

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