Yes you're right: I could've sworn I tried that in the repl a minute
ago and it worked, but actually it's a no-op and appends nothing to
the hash.

This is okay, doing it the other way (without the inner parens around
the colonpair) is not:

ny %stash;
my @monsters = << godzilla grendel wormface blob >>;
my @rabbits = << bugs peter easter >>;

%stash.append( (:@monsters) );
%stash.append( (:@rabbits) );

say %stash;


On 3/17/20, Vadim Belman <vr...@lflat.org> wrote:
>
> Joseph, you've got yourself into a trap I fell into yesterday.
> %stash.append( :@stuff ) syntax is about calling append method with a named
> parameter stuff whereas append works with positionals only. So, your case
> should be written:
>
> %stash.append( (:@stuff) );
>
> Which is apparently more cumbersome. In either case, use of colons is not
> always about saving a character or two. Sometimes it's about readability,
> sometimes about elegance. Overuse is surely bad, but overuse of anything is
> bad, for that matter. :)
>
> Best regards,
> Vadim Belman
>
>> On Mar 17, 2020, at 1:09 PM, Joseph Brenner <doom...@gmail.com> wrote:
>>
>>> Though I've no idea what those colons are/are not doing.
>>
>> Those are "colon pairs" (which I've relearned around three times now...):
>>
>>   https://docs.raku.org/language/glossary#index-entry-Colon_Pair
>> <https://docs.raku.org/language/glossary#index-entry-Colon_Pair>
>>
>> Except for this colon:
>>
>>  %stash.append: (rocks => @rocks);
>>
>> Which is a short hand for this:
>>
>>  %stash.append( (rocks => @rocks) );
>>
>> As an aside: it's a minor style point, but I think a lot of
>> us overuse that trick-- it saves a character, but the explicit
>> parens are more flexible.
>>
>> Notably this works fine, so here it doesn't even save any
>> characters:
>>
>>  %stash.append( :@stuff );
>>
>>
>
>

Reply via email to