File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -585,11 +585,15 @@ X<|postfix ».>
585
585
X < Hyper method call operator > . Will call a method on all elements of a C < List > out of order and return the list of return values in order.
586
586
587
587
my @a = <a b c>;
588
- @a».say; # abc
589
588
my @b = @a».ord; # [97, 98, 99]
590
589
sub foo(Str:D $c){ $c.ord * 2 }; # The first parameter of a method is the invocant.
591
590
say @a».&foo; # So we can pretend to have a method call with a sub that got a good first positional argument.
592
- say @a».&{ .ord}; # Blocks have an implicit positional arguments that lands in $_. The latter can be omitted for method calls.
591
+ say @a».&{ .ord}; # Blocks have an implicit positional arguments that lands in $_. The latter can be omitted for method calls.
592
+
593
+ Take care to avoid a common mistake of expecting side-effects to occur in order. The following
594
+ C < say > is B < not > guaranteed to produce the output in order:
595
+
596
+ @a».say; # WRONG! Could produce abc or cba or any other order
593
597
594
598
= head2 postfix C < .postfix > / C < .postcircumfix >
595
599
X < |.( ) > X < |.[ ] > X < |.{ } >
You can’t perform that action at this time.
0 commit comments