> On 1 Jun 2017, at 16:29, Gabor Szabo <szab...@gmail.com> wrote:
> 
> use v6;
> 
> my @x = { name => "Foo" }, { name => "Bar"}
> say @x.gist;     # [{name => Foo} {name => Bar}]
> say @x.^name;    # Array
> say @x[0].^name; # Hash
> 
> my @y = { name => "Foo" }
> say @y;           # [name => Foo]
> say @y.^name;     # Array
> say @y[0].^name;  # Pair
> 
> my @z = { name => "Foo" },;
> say @z;           # [{name => Foo}]
> say @z.^name;     # Array
> say @z[0].^name;  #  Hash
> 
> 
> In the first example, creating an array of 2 hashes work.
> In the second example the listy assignment removes the hashy-ness of
> the right hand side.
> In the 3rd example adding a comma at the end solves the problem.
> 
> Is this how it is recommended to initiate an array with a single hash?
> Is there an operator that forces the assignment to item-assignment?

FWIW, this follows out of the 1 argument rule:

$ 6 'for { a => 42 } { dd $_ }'
:a(42)

$ 6 'for { a => 42 }, { b => 666 } { dd $_ }'
Hash % = {:a(42)}
Hash % = {:b(666)}

If only 1 argument is specified, it will be iterated over.  And you could 
consider list assignment also such a case (as it internally calls @x.STORE in 
that case).



Liz

Reply via email to