Skip to content

Commit 21c256f

Browse files
committed
Adds straightforward example for feed operator
Response to: The documentation on ==> should get to the point faster #2316
1 parent 1be2f24 commit 21c256f

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

doc/Language/operators.pod6

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2630,6 +2630,19 @@ operands are false, returns the last one.
26302630
This X<feed> operator takes the result from the left and passes it to the
26312631
next (right) routine as the last parameter.
26322632
2633+
my @array = (1, 2, 3, 4, 5);
2634+
@array ==> sum() ==> say(); # OUTPUT: «15␤»
2635+
2636+
This simple example, above, is the equivalent of writing:
2637+
2638+
my @array = (1, 2, 3, 4, 5);
2639+
say(sum(@array)); # OUTPUT: «15␤»
2640+
2641+
Or if using methods:
2642+
2643+
my @array = (1, 2, 3, 4, 5);
2644+
@array.sum.say; # OUTPUT: «15␤»
2645+
26332646
The precedence is very loose so you will need to use parentheses to
26342647
assign the result or you can even just use another feed operator! In the
26352648
case of routines/methods that take a single argument or where the first argument

0 commit comments

Comments
 (0)