lkuty
Elixir 1.13.2 and the deprecation of Map.map/2
I don’t understand how Map.new/2 is a drop-in replacement of Map.map/2 since I get an error when I swap them. Maybe this is obvious but I don’t get it 
$ iex
Erlang/OTP 24 [erts-12.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit] [dtrace]
Interactive Elixir (1.13.2) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> m=%{1=>1,2=>2}
%{1 => 1, 2 => 2}
iex(2)> Map.map(m, fn {_k,v} -> v + 10 end)
warning: Map.map/2 is deprecated. Use Map.new/2 instead
iex:2
%{1 => 11, 2 => 12}
iex(3)> Map.new(m, fn {_k,v} -> v + 10 end)
** (ArgumentError) argument error
(stdlib 3.17) :maps.from_list('\v\f')
(elixir 1.13.2) lib/map.ex:220: Map.new/2
Marked As Solved
kartheek
Also Liked
princemaple
I think that’s a regression in Bring back filter/reject on Map and Keyword · elixir-lang/elixir@e987779 · GitHub
Which was then fixed in Optimize Map.new/2 · elixir-lang/elixir@31739ad · GitHub
Map.new will replace Enum.map on maps. For now I think you should still use Enum.map and into, if needed.
@kartheek is right. I didn’t look at the code carefully enough.
2
lkuty
ok, thanks 
1
Popular in Questions
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
What is the proper way to load a module from a file in to IEX?
In the python world, doing something like this pretty standard:
from ....
New
In Ruby, I can go:
User.find_by(email: "foobar@email.com").update(email: "hello@email.com")
How can I do something similar in Elixir? ...
New
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
I would like to know what is the best IDE for elixir development?
New
I have a list say
x = ["23gh", "56kh", "97mh"]
I would like to pass each element to Val in each iteration.
Say, in iteration 1 -------...
New
I’m currently trying to understand how to join three tables using Ecto. All the examples I’ve seen use 2, so maybe I’m just missing somet...
New
Hello, I have map which I want to convert it to string like this:
the map:
%{last_name: "tavakkoli", name: "shahryar"}
the string I ne...
New
Hi guys, nice to meet you to the whole forum, I’m new here, I’m trying to configure visual studio code for elixir, right now the intellis...
New
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
Other popular topics
Hi everyone!
I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
Hello, I get Persian date from my client and convert it to normal calendar like this:
def jalali_string_to_miladi_english_number(persi...
New
i’m a new one to elixir
which editor can i use
vs code? or atom?
Thanks! :smiley:
New
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
New
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
You’re a programmer, so you don’t need spoon feeding with the conventional drivel about “this is an integer.” No. You need to know what’s...
New
Hi folks,
Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
New
Hey,
Just curious what are the main benefits of Elixir compared to Clojure?
When is Elixir more useful than Clojure and vice versa?
Th...
New
I will often find my self writing things similar to:
case some_value do
nil -> something()
"" -> something()
_ -> someth...
New







