Hello everybody,
I propose the support of Map.take_in/2 to extract values using nested keys
(recursively).
I think it may be useful when you only want a part of the map -- mostly
when its deep nested map (i.e KV stores, DB engines, etc..) to reduce
memory footprint with copy and message passing.
Example:
iex> Map.take_in(%{a: "hello", b: %{c: "hi", d: "hola"}}, [:a, b: [:d]])
%{a: "hello", b: %{d: "hola"}}
As discussed in the #1029 <https://github.com/elixir-lang/elixir/pull/10296>
the feature should be extended to Access for both Map and Keyword
implementation.
To analyse the efficiency regarding pattern matching.
But it's a way to resolve the duplication from pattern matching as in this
example.
iex> %{a: a, b: %{d: d}} = %{a: "hello", b: %{c: "hi", d: "hola"}}
iex> %{a: a, b: %{d: d}}
%{a: "hello", b: %{d: "hola"}}
Thanks :)
--
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/a21054d9-dc18-4a4e-add5-c2e38777fc1dn%40googlegroups.com.