Elixir: Pattern matching for maps
🚧 In development
Instructions
🚧 In development
If you've reached a deadlock it's time to ask your question in the «Discussions». How ask a question correctly:
- Be sure to attach the test output, without it it's almost impossible to figure out what went wrong, even if you show your code. It's complicated for developers to execute code in their heads, but having a mistake before their eyes most probably will be helpful.
Elixir: Pattern matching for maps
🚧 In development
Instructions
🚧 In development
If you've reached a deadlock it's time to ask your question in the «Discussions». How ask a question correctly:
- Be sure to attach the test output, without it it's almost impossible to figure out what went wrong, even if you show your code. It's complicated for developers to execute code in their heads, but having a mistake before their eyes most probably will be helpful.
Your exercise will be checked with these tests:
defmodule Test do
use ExUnit.Case
import Solution
test "get_values test" do
assert {1, 2} = get_values(%{a: 1, b: 2})
assert {:ok, 42} = get_values(%{a: :ok, b: 42, c: true})
end
test "get_values invalid input test" do
assert_raise MatchError, fn ->
get_values(%{})
end
end
test "get_value_by_key test" do
assert 42 = get_value_by_key(%{answer: 42}, :answer)
assert "6 * 7" = get_value_by_key(%{question: "6 * 7"}, :question)
end
test "get_value_by_key invalid input test" do
assert_raise MatchError, fn ->
get_value_by_key(%{a: 1}, :b)
end
end
endTeacher's solution will be available in:
20:00
