Course of Raku / Essentials / More about types / Positional data types
Nested arrays
Arrays can contain any other data, including other arrays. To delimit the borders of the nested arrays, use square brackets:
my @table =
[1, 2, 3, 4],
[10, 20, 30, 40],
[100, 200, 300, 400];It is also possible to have one more pair of brackets for the top-level array. The next example shows the same data structure as before.
my @table = [
[1, 2, 3, 4],
[10, 20, 30, 40],
[100, 200, 300, 400]
];To access inner items, add as many indices as needed. A single pair of square brackets goes down one level deeper into the structure:
say @table[0][3]; # Prints 4
say @table[2][1]; # Prints 200 Practice
Complete the quiz that covers the contents of this topic.
Course navigation
← Quiz — Arrays | Quiz — Nested arrays →
💪 Or jump directly to the exercises in this
section.
Translations of this page: English • Deutsch • Español • Italiano • Latviešu • Nederlands • Български • Русский • Українська