Skip to content

Instantly share code, notes, and snippets.

@knewter
Last active December 27, 2015 03:29
Show Gist options
  • Save knewter/7260284 to your computer and use it in GitHub Desktop.
Save knewter/7260284 to your computer and use it in GitHub Desktop.
defmodule PersonPrinter do
def say_hello(Person[first_name: first, last_name: "Dudington"]) do
"hey it's my brother, #{first}!"
end
def say_hello(Person[first_name: first]) do
"hello, #{first}"
end
def say_hello(person=Person[last_name: "Dudington"]) do
"hey #{person.first_name}"
end
end
bro = Person.new first_name: "Bro", last_name: "Dudington"
stranger = Person.new first_name: "Stranger", last_name: "von Strangehands"
PersonPrinter.say_hello(bro)
PersonPrinter.say_hello(stranger)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment