Last active
March 8, 2017 08:34
-
-
Save blackode/b0c1d4ead9d42c59231b84aa61bcad65 to your computer and use it in GitHub Desktop.
when conditions as functions
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 Hello do | |
def hello(name,age) when is_kid(age) do | |
IO.puts "Hello Kid #{name}" | |
end | |
def hello(name,age) when is_adult(age) do | |
IO.puts "Hello Mister #{name}" | |
end | |
def is_kid age do | |
age < 12 | |
end | |
def is_adult age do | |
age > 18 | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment