Documentation for infix ==>, assembled from the following types:
This feed operator takes the result from the left and passes it to the next (right) routine as the last parameter.
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 is a block, it's often required that you call with parentheses (though this is not required for the very last routine/method).
# Traditional structure, read bottom-to-topmy =sort # (4) Sort, result is <Earth People>grep , # (3) Look for P or Emap , # (2) Capitalize the words<people of earth>; # (1) Start with the input# Feed (left-to-right) with parentheses, read top-to-bottommy = (<people of earth> # (1) Start with the input==> map() # (2) Capitalize the words==> grep /<[PE]>/ # (3) Look for P or E==> sort # (4) Sort, result is <Earth People>);# For illustration, method chaining equivalent, read top-to-bottommy =<people of earth> # (1) Start with the input.map() # (2) Capitalize the words.grep(//) # (3) Look for P or E.sort; # (4) Sort, result is <Earth People># To assign without the need of parentheses use another feed operatormy ;<people of earth>==> map()==> grep /<[PE]>/==> sort()==> ;# It can be useful to capture a partial result, however, unlike# the leftward feed operator, it does require parentheses or a semicolonmy ;<people of earth>==> map()==> my ; # also could wrap in parentheses instead==> grep /<[PE]>/==> sort()==> ;
The feed operator lets you construct method-chaining-like patterns out of routines and the results of methods on unrelated data. In method-chaining, you are restricted to the methods available on the data or the result of previous method call. With feed operators, that restriction is gone. The resulting code could also be seen to be more readable than a series of method calls broken over multiple lines.
Note: In the future, this operator will see some change as it gains the ability to run list operations in parallel. It will enforce that the left operand is enclosable as a closure (that can be cloned and run in a subthread).