Skip to content

Instantly share code, notes, and snippets.

@allenyang79
Created February 14, 2018 06:46
Show Gist options
  • Select an option

  • Save allenyang79/c7ade77bf12752d598bc67f5136614f5 to your computer and use it in GitHub Desktop.

Select an option

Save allenyang79/c7ade77bf12752d598bc67f5136614f5 to your computer and use it in GitHub Desktop.
test elixir `with` syntax #elixir
defmodule Foo do
def foo(a,b) do
with {:ok, dob} <- a,
{:ok, name} <- b
do
%{dob: dob, name: name}
else
# nil -> {:error, ...} an example that we can match here too
# err -> err
_ -> :err
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment