Skip to content

Commit

Permalink
Adds straightforward example for feed operator
Browse files Browse the repository at this point in the history
Response to:
The documentation on ==> should get to the point faster #2316
  • Loading branch information
MorayJ committed Sep 18, 2018
1 parent 1be2f24 commit 21c256f
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions doc/Language/operators.pod6
Expand Up @@ -2630,6 +2630,19 @@ operands are false, returns the last one.
This X<feed> operator takes the result from the left and passes it to the
next (right) routine as the last parameter.
my @array = (1, 2, 3, 4, 5);
@array ==> sum() ==> say(); # OUTPUT: «15␤»
This simple example, above, is the equivalent of writing:
my @array = (1, 2, 3, 4, 5);
say(sum(@array)); # OUTPUT: «15␤»
Or if using methods:
my @array = (1, 2, 3, 4, 5);
@array.sum.say; # OUTPUT: «15␤»
The precedence is very loose so you will need to use parentheses to
assign the result or you can even just use another feed operator! In the
case of routines/methods that take a single argument or where the first argument
Expand Down

0 comments on commit 21c256f

Please sign in to comment.