Skip to content

Instantly share code, notes, and snippets.

@nyo16
Last active December 15, 2018 16:51
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 nyo16/dd9a7c6a40d049f916f046b08a5dc78b to your computer and use it in GitHub Desktop.
Save nyo16/dd9a7c6a40d049f916f046b08a5dc78b to your computer and use it in GitHub Desktop.
example in elixir
def is_active(nil), do: {:error, :not_found}
def is_active(%User{accounts: []}), do: {:error, :no_active_account}
def is_active(%User{accounts: accounts} = user), do: {:ok, user}
def is_active(_), do: {:error, :something_happend}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment