Try vs Case: The last battle
In this article we’ll try to battle different Elixir control structures in order to understand their efficiency and applicability in our projects.
TL;DR:
- You can use
try
withelse
- instead ofcase
literally (only literally!);- Never use
with
instead ofcase
- only instead ofcase
chains;- Use
try
if you need it - forcatch
cases;- Forget about
throw
andcatch
in your code - they are really slow;
Do you want to know, what literally means? Welcome under cut!