Hey there, there is no built-in way to do this. However, thanks to Elixir's extensibility, there are libraries that let you do something very similar to it. Check out https://github.com/whatyouhide/short_maps for example.
On Tue, 22 May 2018 at 19:38, Siraj Kakeh <[email protected]> wrote: > Hello! > I have been working with Elixir on production level for 6 months. I find > myself regularly doing pattern matching similar to this way: > %{"id" => id,firstname: firstname, ...} = person_map > I come from a Javascript background and recently destructing was added to > JS that pretty much looks like pattern matching in Elixir with the > difference that I was able to do this in JS: > { id, firstName } = personObject > * please don't mind the camel case, I know how sensitive Elixir developers > are to that 😄* > I was wondering if there was a way to make pattern matching like that in > Elixir, for example the code above will be something like this: > %{ id, firstname, ...} = person_map > Maybe make that possible only on atom map keys to avoid converting between > strings and atoms, or add a macro that does that. > I would love to hear your opinion, it's something that is done all the > time on pattern matching and honestly I'm a little jealous JS can do that > but Elixir `the mother of pattern matching` can't! > > -- > 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/9be39b53-4884-4ca2-adfb-d1dd7c4223f5%40googlegroups.com > <https://groups.google.com/d/msgid/elixir-lang-core/9be39b53-4884-4ca2-adfb-d1dd7c4223f5%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- Andrea Leopardi [email protected] -- 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/CAM9Rf%2B%2BVqOsw8EFh2QS8kpBEvo%2B7Z-BoTz-Hbq90w%3DiMQEEG7g%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
