Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR ELIXIR

elixir change map key name

iex> details = %{name: "john", address1: "heaven", mobile1: "999999999"}
# %{address1: "heaven", mobile1: "999999999", name: "john"}

iex> Map.new(details, fn  
  {:address1, address} -> {:address, address}
  {:mobile1, mobile} -> {:phone, mobile} 
  x -> x 
end)
# %{address: "heaven", name: "john", phone: "999999999"}
 
PREVIOUS NEXT
Tagged: #elixir #change #map #key
ADD COMMENT
Topic
Name
3+5 =