Skip to content

Commit 4b61173

Browse files
author
José Valim
committed
Mention function capturing alonside partials
1 parent 693804b commit 4b61173

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

crash-course.markdown

+3-2
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ Enum.map [1, 2, 3], &Math.square/1
664664
```
665665

666666

667-
### Partials in Elixir
667+
### Partials and function captures in Elixir
668668

669669
Elixir supports partial application of functions which can be used to define anonymous functions in a concise way:
670670

@@ -676,7 +676,7 @@ List.foldl [1, 2, 3, 4], 0, &(&1 + &2)
676676
#=> 10
677677
```
678678

679-
Partials also allow us to pass named functions as arguments.
679+
We use the same `&` operator to capture a function, allowing us to pass named functions as arguments.
680680

681681
```elixir
682682
defmodule Math do
@@ -689,6 +689,7 @@ Enum.map [1, 2, 3], &Math.square/1
689689
#=> [1, 4, 9]
690690
```
691691

692+
The above would be equivalent to Erlang's `fun math:square/1`.
692693

693694
## Control flow
694695

0 commit comments

Comments
 (0)