Skip to content

Instantly share code, notes, and snippets.

@allenyang79
Created March 14, 2018 18:18
Show Gist options
  • Save allenyang79/eb22a62e61fc13176c57199c834735ab to your computer and use it in GitHub Desktop.
Save allenyang79/eb22a62e61fc13176c57199c834735ab to your computer and use it in GitHub Desktop.
elixir pattern match on case
defmodule MyMod do
defstruct ~w|foo bar|a
def hello(v) do
case v do
%{foo: _foo} = v -> IO.puts(_foo)
_ -> :oops
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment