Added pattern matching koan for keyword list

This commit is contained in:
codefupanda
2017-07-11 22:05:07 +05:30
parent 95e87c3fd8
commit 7a9f04dd45
2 changed files with 7 additions and 0 deletions

View File

@@ -45,6 +45,12 @@ defmodule PatternMatching do
end
end
koan "So does the keyword lists" do
kw_list = [type: "car", year: 2016, make: "Honda"]
[_type | [_year | [tuple]]] = kw_list
assert tuple == {___, ___}
end
koan "The pattern can make assertions about what it expects" do
assert match?([1, _second, _third], ___)
end

View File

@@ -11,6 +11,7 @@ defmodule PatternsTests do
"eggs, milk",
"Honda",
MatchError,
{:multiple, [:make, "Honda"]},
[1,2,3],
{:multiple, ["Meow", "Woof", "Eh?"]},
{:multiple, ["Mickey", "Donald", "I need a name!"]},