an
|> into

So, I used to do:

token
|> Enum.map(fn {:token_name, name} -> {:name, name}
               {:eth_address, eth_address} -> {:address, eth_address}
   end)
|> Enum.into(%{})
|> Map.merge(token_data)

It turns out I only needed Enum.into/3:

token
Enum.into(token, token_data, fn
  {:token_name, name} -> {:name, name}
  {:eth_address, eth_address} -> {:address, eth_address}
end)

And now I finished this tiny refactor.


—


to go back