Itemization helps:

m: my %h = x => 6, y => 7; my @a = $%h; say @a[0]
rakudo-moar 0132b6: OUTPUT«x => 6, y => 7␤»

m: my %h = x => 6, y => 7; my @a; @a.push: $%h; say @a[0]
rakudo-moar 0132b6: OUTPUT«x => 6, y => 7␤»

Am 26.09.2015 um 07:58 schrieb Gabor Szabo:
> In the first two cases the hash was converted to Pairs before
> assigning to the array.
> Only the third case gave what I hoped for. How can I push a hash onto
> an array as a single entity?
>
>
> use v6;
>
> my %h = x => 6, y => 7;
> say %h.perl;     #  {:x(6), :y(7)}
>
> my @a = %h;
> say @a.elems;   #
> say @a[0];         # x => 6
>
>
>
> my @c;
> @c.push(%h);
> say @c.elems;     # 2
> say @c[0];           # x => 6
>
>
> my @b;
> @b[@b.elems] = %h;
> say @b.elems;  # 1
> say @b[0];        # x => 6, y => 7
>
>

Reply via email to