@@ -313,9 +313,9 @@ its return value will be used instead of the original C<@list>'s item:
313
313
314
314
Defined as:
315
315
316
- multi method push(Hash:D: *@ new)
316
+ method push(Hash:D: + new)
317
317
318
- Adds the C < @ new> elements to the hash with the same semantics as hash
318
+ Adds the C < new > elements to the hash with the same semantics as hash
319
319
assignment, but with three exceptions:
320
320
321
321
= item The hash isn't emptied first, i.e. old pairs are not deleted.
@@ -336,15 +336,13 @@ Example:
336
336
%h.push('c' => 4); # a => [1,1,1,1,1], b => 3, c => 4
337
337
push %h, 'd' => 5; # a => [1,1,1,1,1], b => 3, c => 4, d => 5
338
338
339
- Please note that C < Pair > s or
340
- L < colon pairs|/language/glossary#index-entry-Colon_Pair > as arguments to push
341
- will be treated as extra named arguments and as such wont end up the C < Hash > .
342
- The same applies to the sub C < push > .
339
+ Please note that literal pairs in the argument list may be interpreted as
340
+ L < named arguments|/type/Capture > and as such won't end up in the C < Hash > .
341
+ The C < push > subroutine will throw if it receives a named argument.
343
342
344
343
my %h .= push(e => 6);
345
- push %h, f => 7;
346
- say %h.raku;
347
- # OUTPUT: «{}»
344
+ try push %h, f => 7;
345
+ say %h.raku; # OUTPUT: «{}»
348
346
349
347
Also note that push can be used as a replacement for assignment during hash
350
348
initialization very useful ways. Take for instance the case of an inverted
0 commit comments