Course of Raku / Advanced / Containers / Ordered containers / Exercises

Alias an array

Problem

You are given an array:

my @original = 10, 20, 30;

Create a second name, @alias, that refers to the same array (do not copy it). This time, push a new element onto @original, and then print @alias to show that the alias sees not just value changes but structural ones too.

Example

The program prints:

[10 20 30 40]

Solution

See the solution

Course navigation

Quiz — Nesting arrays   |   Solution: Alias an array