Skip to content

Instantly share code, notes, and snippets.

@joeljackson
Last active March 25, 2016 02:42
Show Gist options
  • Select an option

  • Save joeljackson/6023c6f7cb3a233c39d0 to your computer and use it in GitHub Desktop.

Select an option

Save joeljackson/6023c6f7cb3a233c39d0 to your computer and use it in GitHub Desktop.
better function matching in elixir
add_subscription(user, subscription)
def add_subscription(%User{subscription: nil} = user, subscription) do
#Add subscription here using user
end
def add_subscription(_user, _subscription) do
raise "This user already has a subscription"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment