Rename function. format_result() -> inspirational_quote()

This commit is contained in:
Shannon Oram
2018-07-08 12:18:30 +10:00
parent 678d15de07
commit 362cbf77c0

View File

@@ -79,13 +79,13 @@ defmodule Functions do
end end
koan "You can use pattern matching to define multiple cases for anonymous functions" do koan "You can use pattern matching to define multiple cases for anonymous functions" do
format_result = fn inspirational_quote = fn
{:ok, result} -> "Success is #{result}" {:ok, result} -> "Success is #{result}"
{:error, reason} -> "You just lost #{reason}" {:error, reason} -> "You just lost #{reason}"
end end
assert format_result.({:ok, "no accident"}) == ___ assert inspirational_quote.({:ok, "no accident"}) == ___
assert format_result.({:error, "the game"}) == ___ assert inspirational_quote.({:error, "the game"}) == ___
end end
def times_five_and_then(number, fun), do: fun.(number * 5) def times_five_and_then(number, fun), do: fun.(number * 5)