Skip to content

Instantly share code, notes, and snippets.

@Tombarr
Created January 9, 2019 14:39
Show Gist options
  • Save Tombarr/ef119fe8c159cd8c04933efba06f63e6 to your computer and use it in GitHub Desktop.
Save Tombarr/ef119fe8c159cd8c04933efba06f63e6 to your computer and use it in GitHub Desktop.
Using "type check" functions in Guards
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