The following code (with comments) is confusing me.
Can someone give some explanation please?
Specifically the difference between

my @x = <a b>;
my $z = @x;


my $z = <a b>;


use v6;

# < > creates an array here:
my @x = <a b>;
say @x.WHICH;  # Array|140713422866208
say @x;        # a b
say @x[0];     # a
say @x;        # a b c

# we can assign that array to a scalar variable and it is still and array
my $y = @x;
say $y.WHICH;     # Array|140498399577376
say $y[0];        # a
say $y;           # a b c d

# but if we assign the same < > construct directly to a scalar
# then we get a Parcel
my $z = <a b>;
say $z.WHICH;     # Parcel|(Str|a)(Str|b)
# $z.push('c');   # Cannot call push(Parcel: Str); none of these signatures
match: (Any:U \SELF: *@values, *%_)

# but if we wrap it in square brackets it creates an array
my $w = [<a b>];
say $w.WHICH;    # Array|140272330353168
say $w[0];       # a
say $w;          # a b c

Reply via email to