Boost up your elixir by
10 Killer Elixir Tips #8
Do the things every day, you will find better
Hey guys!
Welcome back to another set of killer elixir tips.
Check out the previous articles of this series
Killer Elixir Tips#1 #2 #3 #4 #5 #6 #7
I am using the following development stack at the moment of writing this article.
Hex: 0.18.1
Elixir: 1.7.3
OTP: 21.1.1
1— Replacing a Key in Map
I know, you might be thinking why some one would do that. I too had the same feeling until I met with a requirement in one of my previous projects where I was asked to replace address1
with address
and some other keys as well. It is a huge one. I have to do change many keys as well.
I’m here with a simple map to keep it understandable. But, the technique is same.
The thing to remember is; be smart and stay long;
details = %{name: "john", address1: "heaven", mobile1: "999999999"}
The above map comprises of two weird keys address1
and mobile1
where we do workout on to take over them.
iex> details = %{name: "john", address1: "heaven", mobile1…