Add example of matching map with struct
This commit is contained in:
@@ -110,4 +110,9 @@ defmodule PatternMatching do
|
||||
%Animal{name: name} = %Animal{kind: "dog", name: "Max"}
|
||||
assert name == ___
|
||||
end
|
||||
|
||||
koan "Structs will even match with a regular map" do
|
||||
%{name: name} = %Animal{kind: "dog", name: "Max"}
|
||||
assert name == ___
|
||||
end
|
||||
end
|
||||
|
||||
@@ -19,6 +19,7 @@ defmodule PatternsTests do
|
||||
{:multiple, ["Mickey", "Donald", "I need a name!"]},
|
||||
"dog",
|
||||
"Max",
|
||||
"Max",
|
||||
]
|
||||
|
||||
test_all(PatternMatching, answers)
|
||||
|
||||
Reference in New Issue
Block a user