๐Ÿ“˜ Array in Perl 6

๐Ÿ“˜ Array in Raku

N. B. Perl 6 has been renamed to Raku. Click to read more.


The Array variables (i.e., all the variables starting with the @ sigil) are equipped with a couple of simple but rather useful methods.

my @a = 1, 2, 3, 5, 7, 11;
say @a.Int; # array length
say @a.Str; # space-separated values

If you print an array, you get its value as a space-separated list in square brackets. Alternatively, you may interpolate it in a string.

my @a = 1, 2, 3, 5, 7, 11;

say @a;ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย  ย # [1 2 3 5 7 11]
say "This is @a: @a[]"; # This is @a: 1 2 3 5 7 11

Leave a Reply

Your email address will not be published. Required fields are marked *

Retype the CAPTCHA code from the image
Change the CAPTCHA codeSpeak the CAPTCHA code