To boost your Elixir coding, you need to understand a few differences between these two even though they are used for the same purpose.
hd ( vs ) List.first [ diff…]
We all knew that
List.first are used to pick out the
first element in
list . But, why two functions for the same purpose?
However, they differ slightly in dealing with the empty list
 and in guard tests.
- on Empty listsThe function
hdon empty list
List.firston empty list
- on guard testsThe function
hdis allowed in guard tests. In lined by the compiler.
List.firstis** not allowed in **guard tests.
Lets check this in live
Hope you got some idea and understood where and when to use them.
Guys, I love to hear more on this through reply which would help the programmers to write the better code.
Sharing is Caring !!
Thanks for the support you have shown in reading and clapping the previous parts of this category.
If you want to read more on this kinda things, check below.
Read all parts of Killer Elixir Tips and download
README.MD file at
Click on link All 10 Killer Elixir Tips Parts. Contribute with a ★
Happy Coding !!