[erlang-questions] Updating a map

Fred Youhanaie fly@REDACTED
Wed Jan 30 14:13:38 CET 2019


You can use the maps:fold/3, e.g.

M = #{one => 1, two => 2, three => 3}.

maps:fold(fun maps:update/3, M, #{one=>11, two=>22}).
#{one => 11,three => 3,two => 22}

Cheers,
Fred

On 30/01/2019 12:27, Donald Steven wrote:
> The documentation for maps:update states:  update(Key, Value, Map1) -> Map2, but since update has an arity of 3, this doesn't work: update(Key1, Value1, Key2, Value2, Map1) -> Map2.  Is there an 
> other-than one-by-one-sequential-update to update more than one key-value in one shot?
> 
> Thanks.
> 
> 
> Don
> 
> 
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions



More information about the erlang-questions mailing list