FYI: https://github.com/whatyouhide/short_maps

On Thu, Jun 1, 2017 at 3:04 PM, Sheharyar Naseer <[email protected]
> wrote:

> Most Elixir devs will agree with me, that when pattern matching on Maps,
> the variable names are usually the same as the keys:
>
> 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 
> <https://gist.github.com/mikaelbr/9900818#file-destructuring-js-L66>):
>
> %{ 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 [email protected].
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/elixir-lang-core/1d79fb43-8385-46d2-b4c9-
> 8acca1c2407f%40googlegroups.com
> <https://groups.google.com/d/msgid/elixir-lang-core/1d79fb43-8385-46d2-b4c9-8acca1c2407f%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> 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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/CAHsFyS8as8QDZd8T1wk-_CrGBnzDteNgfNAidG4JS7q_z8%2BLNg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to