On 07/31/2015 03:02 PM, Gabor Szabo wrote:
The following code (with comments) is confusing me. Can someone give some explanation please? Specifically the difference between my @x = <a b>;
It's the assignment to the Array variable that makes the Array here; < > by itself just creates a Parcel:
$ ./perl6-m -e 'say <a b>.^name' Parcel $ ./perl6-m -e 'say (my @ = <a b> ).^name' Array
# we can assign that array to a scalar variable and it is still and array my $y = @x;
that's because assignment to $ isn't coercive in the same way as assignment to @ or %.
It just wraps things into a Scalar, which is normally invisible. But, you can observe the difference still> my @a = <a b>; my $s = @a' for @a { } # two iterations for $s { } # one iteration Cheers, Moritz