79403677

Date: 2025-01-31 18:19:23
Score: 0.5
Natty:
Report link

Seems all the above solutions are pretty valid. Anyway you could just:

Enum.map(%{:a => 2}, fn {k, v} -> {k, v + 1} end) |> Map.new()

Enum parses maps in a list of tuples of {k, v} pair, so Map can handle it back. Same logic is applied with Keyword.

Eg

iex(3)> [{:a, 1}, {:b, 2}] |> Keyword.new() [a: 1, b: 2]

Reasons:
  • Low length (0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: icra