79419305

Date: 2025-02-06 20:48:36
Score: 0.5
Natty:
Report link

I'd define the following function:

def rename(map, old_key, new_key) do
  case Map.pop(map, old_key) do
    {nil, _} -> map
    {value, map2} -> Map.put(map2, new_key, value)
  end
end

and then it's simply a matter of:

Enum.map(maps, &rename(&1, :code, :product_code))
Reasons:
  • Low length (0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Guy Argo