Skip to content

Instantly share code, notes, and snippets.

@fschuindt
Created April 23, 2016 19:39
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 fschuindt/fcbec81dfc27e26abc6a28014111e70e to your computer and use it in GitHub Desktop.
Save fschuindt/fcbec81dfc27e26abc6a28014111e70e to your computer and use it in GitHub Desktop.
defmodule Math do
def zero?(0) do
true
end
def zero?(x) when is_integer(x) do
false
end
end
IO.puts Math.zero?(0) #=> true
IO.puts Math.zero?(1) #=> false
IO.puts Math.zero?([1, 2, 3]) #=> ** (FunctionClauseError)
IO.puts Math.zero?(0.0) #=> ** (FunctionClauseError)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment