Fetching values of repeated key in keywordlist

This commit is contained in:
codefupanda
2017-07-11 13:39:54 +05:30
parent 4eacb11d47
commit 95e87c3fd8

View File

@@ -15,11 +15,11 @@ defmodule KeywordLists do
assert kw_list[:foo] == ___
end
koan "You could access a second key by removing the first" do
kw_list = [foo: "bar", foo: "baz"]
[_|kw_list] = kw_list
koan "You could access the values of repeating key" do
kw_list = [foo: "bar", foo1: "bar1", foo: "baz"]
values = Keyword.get_values(kw_list, :foo)
assert kw_list[:foo] == ___
assert List.last(values) == ___
end
koan "Keyword lists are just special syntax for lists of two-element tuples" do