Skip to content

Instantly share code, notes, and snippets.

@Qqwy
Last active June 15, 2016 07:06
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 Qqwy/0832e24e1a8b7e628773cfeda3df0f02 to your computer and use it in GitHub Desktop.
Save Qqwy/0832e24e1a8b7e628773cfeda3df0f02 to your computer and use it in GitHub Desktop.
defmodule Bob do
def hey(input) do
cond do
String.strip(input) == "" -> "Fine. Be that way!"
String.ends_with?(input, "?") -> "Sure."
all_letters_uppercase?(input) -> "Whoa, chill out!"
true -> "Whatever."
end
end
defp all_letters_uppercase?(input) do
String.upcase(input) == input
&& (String.downcase(input) != input)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment