Perl 6 Perl 6 Lists, Arrays, and Hashes vivified #14

List interpolation

In general, non-scalars interpolate in lists, and scalars do not:

my @a = 1,2,3;
my @b = 10,20,30;
my $c = [ 100, 200, 300 ];

my @one = (@a, @b);       # 1,2,3,10,20,30
say @one.elems;           # 6

my @two = (@a, @b, $c);   # 1,2,3,10,20,30,[100, 200, 300]
say @two.elems;           # 7

say @two[0];              # 1
say @two[5];              # 30
say @two[6];              # "100 200 300"
Copyright © 2011
http://www.pmichaud.com/2011/pres/