Skip to content

Commit 32f415f

Browse files
author
José Valim
committed
Merge pull request elixir-lang#175 from mikulely/patch-1
Update partial function example
2 parents 440f41d + d60a1dd commit 32f415f

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

getting_started/6.markdown

+5-5
Original file line numberDiff line numberDiff line change
@@ -177,13 +177,13 @@ iex> fun.("hello")
177177
A capture also allows the captured functions to be partially applied, for example:
178178

179179
```iex
180-
iex> fun = &atom_to_binary(&1, :utf8)
181-
#Function<6.17052888 in :erl_eval.expr/5>
182-
iex> fun.(:hello)
183-
"hello"
180+
iex> fun = &rem(&1, 2)
181+
#Function<6.80484245 in :erl_eval.expr/5>
182+
iex> fun.(4)
183+
0
184184
```
185185

186-
In the example above, we use `&1` as a placeholder, generating a function with one argument. The capture above is equivalent to `fn(x) -> atom_to_binary(x, :utf8) end`.
186+
In the example above, we use `&1` as a placeholder, generating a function with one argument. The capture above is equivalent to `fn(x) -> rem(x, 2) end`.
187187

188188
Since operators are treated as regular function calls in Elixir, they are also supported, although they require explicit parentheses:
189189

0 commit comments

Comments
 (0)