On 11/07/2015 02:45 AM, Marc Chantreux wrote:
> hello,
> using perl6 version 2015.09 built on MoarVM version 2015.09,
> i'm trying to create a hash with a slice of another one and some extra 
> pairs. as exemple: 
>     my %x = < login jdoe first john last doe >;
>     my %y = :enable, |( %x< login first >.kv);
> gives 
>     0 => jdoe, 1 => john, enable => True

That's because %x< login first> returns a List of values:

say %x< login first >.perl;     # ("jdoe", "john")

At this point you have lost the keys, and .kv helpfully supplies the
integer indexes of the list as keys.

What you really want is

%x< login first >:p

This works for me:

my %x = < login jdoe first john last doe >;
my %y = flat (:enable, %x< login first >:p);
say %y.perl;                    # {:enable, :first("john"), :login("jdoe")}


Reply via email to