Skip to content

Instantly share code, notes, and snippets.

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 alanpeabody/eaa72deeef8f3c630a36 to your computer and use it in GitHub Desktop.
Save alanpeabody/eaa72deeef8f3c630a36 to your computer and use it in GitHub Desktop.
silly_long_elixir_function_pattern_match.ex
defmodule Post do
def create(%{title: t, body: b, author_id: a} = atts) when is_binary(t) and is_binary(b) and is_binary(a) do
{:ok, Dict.merge(atts, :id, 1234)}
end
def create(_atts) do
{:error, %{error: "Invalid attributes"}}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment