Elixir Pipes

Pipes (|>) use the return value of the last function as the first argument of the next function.

So these are the same:

Enum.map([1, 2, 3], fn n -> n * 2 end)
#=> [2, 4, 6]
[1, 2, 3]
|> Enum.map(fn n -> n * 2 end)
#=> [2, 4, 6]

Fault tolerance is one of the main features. This playlist has a good example of a program that has a function that is designed to crash repeatedly, but the program still completes all of its tasks successfully.

It’s worth checking out. :slight_smile:

1 Like