Hi !

I propose Map.replace/3.

Map.replace!/3 already exists.
However, it is difficult to use pattern match with Map.replace!/3  because 
it raise error when key is not present in map.

So, I think it is a good idea make Map.replace/3  and it return 
:error
when key is not present in map, and it return
{:ok, %{hoge: "hoge"}}
when key is present and work correctly.

Example:
 iex> ex_map = %{a: 1, b: 2}
%{a: 1, b: 2}

 iex>Map.replace(ex_map, :a, 3)
{:ok, %{a: 3, b: 2}}

 iex>Map.replace(ex_map, :hoge, 3)
:error

-- 
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 elixir-lang-core+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/812de3be-6088-41ff-b9fa-6387d86ab1df%40googlegroups.com.

Reply via email to