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 have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
Hi,
is there any work on GUI with Elixir, that is similar to Electron/Javascript? My idea is to bundle Phoenix and BEAM into a single se...
New
I would like to know what is the best IDE for elixir development?
New
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
Hey all, just started picking up Elixir last week and am writing a scraper as a learning project.
Baby step #1 is extracting the number ...
New
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible.
total = 10
while total != 0
...
New
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
After calling mix ecto.create I get this error:
17:00:32.162 [error] GenServer #PID<0.412.0> terminating
** (Postgrex.Error) FATAL...
New
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: )
Hello all, this is ...
New
Mix format works fine if run from the cmd. I’ve followed this to facilitate the implementation into VSC which involves downloading an ext...
New
Other popular topics
Here are few pieces of (common) Linux knowledge that we use for reasonably small one server apps. We use Ubuntu but this should work for ...
New
can someone please explain to me how Enum.reduce works with maps
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
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode.
The solution seems to be, in a hyphena...
New
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine)
This is a plugin that adds support for Elixir to JetBrains IntelliJ...
New
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set?
Thanks.
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 everybody,
usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
I have a super simple question about elixir - how would I take a file like this
foo bar baz
and output a new file that enumerates th...
New







