Skip to content

Commit

Permalink
[elixir/en] Adds elixir documentation on the pipe operator. (adambard…
Browse files Browse the repository at this point in the history
  • Loading branch information
chriszimmerman authored and vendethiel committed Oct 9, 2016
1 parent a18f6a5 commit da26d35
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions elixir.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,14 @@ defmodule MyMod do
IO.inspect(@my_data) #=> 100
end

# The pipe operator |> allows you to pass the output of an expression
# as the first parameter into a function.

Range.new(1,10)
|> Enum.map(fn x -> x * x end)
|> Enum.filter(fn x -> rem(x, 2) == 0 end)
#=> [4, 16, 36, 64, 100]

## ---------------------------
## -- Structs and Exceptions
## ---------------------------
Expand Down

0 comments on commit da26d35

Please sign in to comment.