Skip to content

Instantly share code, notes, and snippets.

@manpages
Last active December 17, 2015 05:29
Show Gist options
  • Save manpages/5558666 to your computer and use it in GitHub Desktop.
Save manpages/5558666 to your computer and use it in GitHub Desktop.
Sad story of Fred and Wilda
iex(1)> defmodule Guards do
...(1)> def love(x, y) when x == 'fred' or y == 'wilda', do: "Fred and Wilda don't love anyone"
...(1)> def love(x, y), do: x ++ 'loves' ++ y
...(1)> end
{:module,Guards,<<70,79,82,49,0,0,7,180,66,69,65,77,65,116,111,109,0,0,0,106,0,0,0,11,13,69,108,105,120,105,114,45,71,117,97,114,100,115,8,95,95,105,110,102,111,95,95,4,100,111,...>>,{:love,2}}
iex(2)> Guards.love 'fred', 'mary'
"Fred and Wilda don't love anyone"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment