Course of Raku / Essentials / Positional data types

Interpolating arrays

To interpolate array elements in double-quoted strings write it as you do in a program itself: @data[1]. To interpolate the whole array, add a pair of empty brackets: @data[]. The following program illustrates this approach:

my @data = 10, 20, 30;

say "First: @data[0], last: @data[1]";
say "All elements: @data[]";

This program prints the requested data:

$ raku t.raku 
First: 10, last: 20
All elements: 10 20 30

Practice

Complete the quiz that covers the contents of this topic.

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БългарскиРусскийУкраїнська