I have seen this somewhere before in a similar format.
I want to pattern match on two keys in a list of maps, sometimes x will be present, sometimes y.
How I could show it:
m = [%{x: 5}, %{y: 7}]
Enum.map(m, fn
%{x: x} ->
IO.puts("matched on x, #{x}")
%{y: y} ->
IO.puts("matched on y #{y}")
end)
I tried this in my IEX and it didn’t work for 15 minutes, that’s why I posted this.
I read the above replies and then retried it and it worked!
Programming…