Thanks Fernando, I should have searched first :)
On Tuesday, 11 February 2020 03:31:56 UTC-5, Fernando Tapia Rico wrote: > > Hi Joshua, > > This has been suggested a few times in the mailing list: > https://groups.google.com/forum/#!searchin/elixir-lang-core/short_maps%7Csort:date > > Hope that helps :) > > On Tuesday, February 11, 2020 at 8:58:45 AM UTC+1, Joshua Nussbaum wrote: >> >> Hi, >> >> What do you think about adding map deconstruction syntax similar to >> JavaScript. It would remove the need to declare the key and binding >> variable when they are identical names. >> >> Often the map keys and binding var use the same name: >> >> # without deconstruction >> %{name: name, email: email} = user >> >> vs >> >> # with deconstruction (identical) >> %{name, email} = user >> >> This would work too for function definitions `def send_email(%{name, >> email}) do ...`, pattern matching ` case user, do: %{name, email} -> ....` >> as well as updates `%{user | email, name}`. >> >> It would also require updating `mix format` to replace `%{key: key}` with >> `%{key}` >> >> Here is a prototype of the changes required to the compiler: >> >> >> https://github.com/elixir-lang/elixir/compare/master...joshnuss:map-destructure >> >> Best, >> Josh >> >> >> >> -- 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/da07cec7-58a7-485d-9b22-03ab2d8aa528%40googlegroups.com.
