Add example of anonymous function as argument
This commit is contained in:
@@ -72,6 +72,11 @@ defmodule Functions do
|
||||
assert times_five_and_then(2, &square/1) == ___
|
||||
end
|
||||
|
||||
koan "The '&' operation is not needed for anonymous functions" do
|
||||
cube = fn number -> number * number * number end
|
||||
assert times_five_and_then(2, cube) == ___
|
||||
end
|
||||
|
||||
koan "Functions can be combined elegantly with the pipe operator" do
|
||||
result = "full-name"
|
||||
|> String.split("-")
|
||||
|
||||
@@ -14,6 +14,7 @@ defmodule FunctionsTests do
|
||||
6,
|
||||
6,
|
||||
100,
|
||||
1000,
|
||||
"Full Name",
|
||||
]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user