Add new koan for anonymous functions with pattern matching

This commit is contained in:
Rabea Gleissner
2016-04-26 12:07:45 +01:00
parent bf1cf2a155
commit 9ec6089bde
2 changed files with 13 additions and 0 deletions

View File

@@ -65,6 +65,18 @@ defmodule PatternMatching do
assert make_noise(snake) == ___
end
koan "And they will only run the code that matches the argument" do
name = fn
("duck") -> "Donald"
("mouse") -> "Mickey"
(_other) -> "I need a name!"
end
assert name.("mouse") == ___
assert name.("duck") == ___
assert name.("donkey") == ___
end
koan "Errors are shaped differently than sucessful results" do
dog = %{type: "dog"}