Skip to content

Instantly share code, notes, and snippets.

@Adzz
Last active May 29, 2018 22:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Adzz/5563fbc33b126404bce50e18705919b9 to your computer and use it in GitHub Desktop.
Save Adzz/5563fbc33b126404bce50e18705919b9 to your computer and use it in GitHub Desktop.
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