Clarify keyword list as options example by including else clause

This commit is contained in:
Jay Hayes
2016-06-13 09:30:43 -05:00
parent 8ccd83677e
commit e522836f09
2 changed files with 7 additions and 2 deletions

View File

@@ -34,9 +34,14 @@ defmodule KeywordLists do
koan "Conveniently keyword lists can be used for function options" do
transform = fn str, opts ->
if opts[:upcase], do: String.upcase(str)
if opts[:upcase] do
String.upcase(str)
else
str
end
end
assert transform.("good", upcase: true) == ___
assert transform.("good", upcase: false) == ___
end
end

View File

@@ -9,7 +9,7 @@ defmodule KeywordListsTests do
"baz",
{:multiple, [:foo, "bar"]},
"foo",
"GOOD",
{:multiple, ["GOOD", "good"]},
]
test_all(KeywordLists, answers)