I'm having trouble writing function clauses where I need to pattern-match against the map and also retain it for use in the function. I'm not able to understand what the syntax will be. Basically I want something like this:
def check_data (arg1, %{"action" => "action1", ...}, arg2) do
# access other keys of the structure
end
I'm sure this is very basic, but it's something that seems to be eluding me. I've gone through many tutorials but can't seem to find one that handles this use case.
def check_data(%{"action" => "action1"} = arg1, arg2)
ordef check_data(arg1, %{"action" => "action1"} = arg2)
? – Dogbert Sep 27 '16 at 9:24arg1 = %{}
inside function parameters? :O – ankush981 Sep 27 '16 at 9:26def check_data(arg1, %{"action" => "action1"} = map, arg2)
? Yes, you can use=
in function parameters. – Dogbert Sep 27 '16 at 9:28