Skip to content

Instantly share code, notes, and snippets.

@imetallica
Last active July 17, 2017 21:05
Show Gist options
  • Select an option

  • Save imetallica/e2250baecb0b4c075eddc70a50e3f3cb to your computer and use it in GitHub Desktop.

Select an option

Save imetallica/e2250baecb0b4c075eddc70a50e3f3cb to your computer and use it in GitHub Desktop.
with
{:ok, width} <- Map.fetch(opts, :width),
{:ok, height} <- Map.fetch(opts, :height)
do
{:ok, width * height}
else
{:error, :wrong_data} -> ...
{:error, :wrong_data_2} -> ...
end
## Ou
my_pipe
|> bar(123)
|> bee(456)
bar({:error, reason}, _), do: {:error, reason}
bar(arg, foo), do: arg + foo
bee({:error, reason}, _), do: {:error, reason}
bee(arg, fee), do: arg + fee
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment