Skip to content

Commit 51eb039

Browse files
authored
Note @A».say; as being an error
1 parent 6687e2d commit 51eb039

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

doc/Language/operators.pod6

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -585,11 +585,15 @@ X<|postfix ».>
585585
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.
586586
587587
my @a = <a b c>;
588-
@a».say; # a␤b␤c␤
589588
my @b = @a».ord; # [97, 98, 99]
590589
sub foo(Str:D $c){ $c.ord * 2 }; # The first parameter of a method is the invocant.
591590
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 a␤b␤c␤ or c␤b␤a␤ or any other order
593597
594598
=head2 postfix C<.postfix> / C<.postcircumfix>
595599
X<|.( )>X<|.[ ]>X<|.{ }>

0 commit comments

Comments
 (0)