FWIW, it's the same as if you would do:

    my @a = ^10;
    my $b = @a;
    dd $b;  # Array $b = $[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

A scalar can only hold a single value.  That single value in $b is an Array.  
But it is still a single value (shown in the output by the $[ ] construct.  
Adding .list of circumfixing it with @( ) makes it a "real" iterable thing 
again:

    dd $b.list;  # Array @a = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
    dd @($b);    # Array @a = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

With regards to slipping, you can actually do this when assigning to the hash 
already, which is handy if you need to iterate more than once over the value 
for that key:

    my @a = ^10;
    my %h = a => @a;
    .say for %h<a>;
    [0 1 2 3 4 5 6 7 8 9]

    my @a = ^10;
    my %h = a => |@a;
    .say for %h<a>;
    0
    1
    2
    etc.

> On 5 Mar 2020, at 04:36, Joseph Brenner <doom...@gmail.com> wrote:
> 
> There might not be much to say about this, I just though I'd
> mention that I keep getting re-surprised by basics with Raku,
> like this one, where first I stash an array away in a hash and
> later try to pull the array out again:
> 
>    my %stash;
>    my @monsters =
>      << godzilla grendel wormface blob fingfangfoom tingler >>;
>    %stash{'monsters'} = @monsters;
> 
> Now some time later, when I wanted to extract that array again,
> my first thought was to do this:
> 
>    my @m = %stash{'monsters'};
> 
> But that doesn't get the original array back, instead you end up
> with the entire original array as the first element of a newly
> created array:
> 
>    # [[godzilla grendel wormface blob fingfangfoom tingler]]
> 
> Yary Hluchan pointed out that I could slip it out, and get what
> I wanted:
> 
>    my @m = | %stash{'monsters'};
>    say @m;
>    # [godzilla grendel wormface blob fingfangfoom tingler]
> 
> Though for what I'm doing now, I think it might be better to
> just alias it with the binding operator:
> 
>   my @m := %stash{'monsters'};
> 
> So, like I said: I don't have any particular questions about this,
> I think I more or less know what's going on... it will be a while
> before I stop tripping over this sort of thing, though.

Reply via email to