Created
January 9, 2019 14:39
-
-
Save Tombarr/ef119fe8c159cd8c04933efba06f63e6 to your computer and use it in GitHub Desktop.
Using "type check" functions in Guards
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 Greet do | |
def hey(name) when is_atom(name) do | |
name |> to_string |> hey | |
end | |
def hey(name) when is_binary(name) do | |
IO.puts "Hello, " <> name | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment