Elixir: Protocols
🚧 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: Protocols
🚧 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
describe "teller protocol work" do
test "for human" do
assert Teller.impl_for(%Human{}) == Teller.Human
assert Teller.say_something(%Human{name: "John"}) == "Hello, world!"
end
test "for dog" do
assert Teller.impl_for(%Dog{}) == Teller.Dog
assert Teller.say_something(%Dog{name: "Barkinson"}) == "Bark, world!"
end
test "for cat" do
assert Teller.impl_for(%Cat{}) == Teller.Cat
assert Teller.say_something(%Cat{name: "Meowington"}) == "Meow, world!"
end
end
endTeacher's solution will be available in:
20:00
