Skip to content

Commit 86ff9ff

Browse files
committed
improve wording and examle
1 parent f594c8e commit 86ff9ff

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

doc/Type/Hash.pod6

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -522,14 +522,15 @@ Example:
522522
%h.push('c' => 4); # a => [1,1,1,1,1], b => 3, c => 4
523523
push %h, 'd' => 5; # a => [1,1,1,1,1], b => 3, c => 4, d => 5
524524
525-
Be careful to quote the keys in the last two methods, as these have no effect:
526-
527-
=for code :skip-test
528-
%h.push(e => 6);
529-
push %h, f => 7;
530-
531-
because they are interpreted as named arguments to C<push>, not positional
532-
arguments.
525+
Please note that C<Pair>s or
526+
L<colon pairs|/language/glossary#index-entry-Colon_Pair> as arguments to push
527+
will be treated as extra named arguments and as such wont end up the C<Hash>.
528+
The same applies to the sub C<push>.
529+
530+
my %h .= push(e => 6);
531+
push %h, f => 7;
532+
say %h.perl;
533+
# OUTPUT: «{}␤»
533534
534535
Also note that push can be used as a replacement for assignment during hash
535536
initialization very useful ways. Take for instance the case of an inverted

0 commit comments

Comments
 (0)