def some_method(%{user: %{id: id, email: email}, action: action, message: message}) do
# do something
end
I propose another way to pattern match Key-Value pairs in Maps, using the variable names alone (Similar to how you destructure objects in ES6):
%{ a, b } = %{a: 1, b: 2}
and
def some_method(%{user: %{ id, email }, action, message}) do
# do something
end
If this makes sense to others, I'm can try doing this and send a PR (if someone can point me in the right direction 😊).
--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-core+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/1d79fb43-8385-46d2-b4c9-8acca1c2407f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
%{name, age} #=> %{name: name, age: age}
%{user | name, age} #=> %{user | name: name, age: age}
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAHsFyS8as8QDZd8T1wk-_CrGBnzDteNgfNAidG4JS7q_z8%2BLNg%40mail.gmail.com.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/1d79fb43-8385-46d2-b4c9-8acca1c2407f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.