Last active
May 29, 2018 22:24
-
-
Save Adzz/5563fbc33b126404bce50e18705919b9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Circle do | |
defstruct [:radius] | |
end | |
defimpl AreaProtocol, for: Circle do | |
def calculate(%Circle{radius: radius}) do | |
3.14 * radius * radius | |
end | |
end | |
Shape.calculate(%Area{}, %Circle{radius: 2}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment