How do I used matched arguments in elixir functions

Viewed 1467

Say I have two use cases for a function. Do something with users that have a subscription and something with users that don't have a subscriptions.

def add_subscription(subscription_id, %User{subscription: nil})
  # Do something with user here.

And

def add_subscription(subscription_id, user)

How do I do pattern matching like this and also still use the user in the first function?

Thanks!

1 Answers
Related