10 Common Code Refactoring Experiences|Elixir
https://medium.com/blackode/elixir-code-refactoring-techniques-33589ac56231
This article comprises of common Elixir coding techniques that you may or may not know.
A Jist of the Article
We usually encounter a situation like we expect a map has certain key and if not we need to send some default value.
Immediately, we will end up using Map.has_key?
like in the following way
currency =
if(Map.has_key? price, "currency") do
price["currency"]
else
"USD"
If you see any such lines in your code then it is time to refactor them as
currency = Map.get(price, "currency", "USD")
However, you can also take this to the next level like
currency = price["currency"] || "USD"