Hi everyone,
Well the whole question fits in the subject...
I was wondering why the pipe operator used in a map was sugar for
Map.update and not Map.put
iex(1)> m=%{foo: 1}
%{foo: 1}
iex(2)> %{m | bar: 2}
** (KeyError) key :bar not found in: %{foo: 1}
(stdlib) :maps.update(:bar, 2, %{foo: 1})
(stdlib) erl_eval.erl:255: anonymous fn/2 in :erl_eval.expr/5
(stdlib) lists.erl:1262: :lists.foldl/3
iex(2)> %{m | foo: 2}
%{foo: 2}
I'm sure it has good reasons, but I'm a little puzzled on why ?
--
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/12285e7a-757d-451b-9a19-2e582d9ccaa3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.