Skip to content

Instantly share code, notes, and snippets.

@Adzz
Created May 27, 2018 10:47
Show Gist options
  • Save Adzz/25301ef6ec8c46c425fd19c2fe26d357 to your computer and use it in GitHub Desktop.
Save Adzz/25301ef6ec8c46c425fd19c2fe26d357 to your computer and use it in GitHub Desktop.
defmodule Square do
defstruct [:side]
end
defmodule Circle do
defstruct [:radius]
end
defprotocol Area do
def calculate_for(shape)
end
defprotocol Perimeter do
def calculate_for(shape)
end
Area.calculate_for(%Square{side: 10})
Perimeter.calculate_for(%Circle{radius: 10})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment