Skip to content

Instantly share code, notes, and snippets.

@tonini
Created April 26, 2016 10:26
Show Gist options
  • Select an option

  • Save tonini/e45482e70fbe9ec90c595b40540772e7 to your computer and use it in GitHub Desktop.

Select an option

Save tonini/e45482e70fbe9ec90c595b40540772e7 to your computer and use it in GitHub Desktop.
defmodule Foo do
def bar do
with {:ok, width} <- Map.fetch(opts, :width),
{:ok, height} <- Map.fetch(opts, :height) do
{:ok, width * height}
else
:error ->
{:error, :wrong_data}
end
end
end
defmodule Foo do
def bar do
with {:ok, width} <- Map.fetch(opts, :width),
{:ok, height} <- Map.fetch(opts, :height),
do: {:ok, width * height},
else: {:error, :wrong_data}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment