mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 15:24:09 +03:00
[elixir/en] Adds elixir documentation on the pipe operator. (#2434)
This commit is contained in:
parent
a18f6a596e
commit
da26d353ae
@ -325,6 +325,14 @@ defmodule MyMod do
|
|||||||
IO.inspect(@my_data) #=> 100
|
IO.inspect(@my_data) #=> 100
|
||||||
end
|
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
|
## -- Structs and Exceptions
|
||||||
## ---------------------------
|
## ---------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user