Skip to content

Instantly share code, notes, and snippets.

@lpil
Last active October 22, 2017 17:43
Show Gist options
  • Save lpil/c782b1ba0f607d4220cea9b048056446 to your computer and use it in GitHub Desktop.
Save lpil/c782b1ba0f607d4220cea9b048056446 to your computer and use it in GitHub Desktop.
Ways of handling nil
id
|> get()
|> Maybe.and_then(& &1.size)
id
|> get()
|> case do
nil ->
nil
entity ->
entity.size
end
id
|> get()
|| %{size: default_size}
|> (& &1.size).()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment