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

Interpolating arrays

To interpolate array elements in double-quoted strings, write them 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

Quiz — The @*ARGS array   |   Quiz — Interpolating arrays


💪 Or jump directly to the exercises in this section.

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