Created
May 27, 2018 10:47
-
-
Save Adzz/25301ef6ec8c46c425fd19c2fe26d357 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 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