Guardas Elixir
defmodule Guard do
def kind_of(x) when is_binary(x) do
"#{x} is a binary"
end
def kind_of(x) when is_atom(x) do
"#{x} is an atom"
end
def is_ten(x) when x > 10, do: "Greater than ten"
def is_ten(x) when x < 10, do: "Less than ten"
def is_ten(x), do: "Yes"
end
Misty Mallard