Created
March 14, 2018 18:18
-
-
Save allenyang79/eb22a62e61fc13176c57199c834735ab to your computer and use it in GitHub Desktop.
elixir pattern match on case
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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