Elixir Language Tips and Tricks Multiple [ OR ]


This is just the other way of writing Multiple OR conditions. This is not the recommended approach because in regular approach when the condition evaluates to true, it stops executing the remaining conditions which save the time of evaluation, unlike this approach which evaluates all conditions first in the list. This is just bad but good for discoveries.

# Regular Approach
find = fn(x) when x>10 or x<5 or x==7 -> x end 

# Our Hack
hell = fn(x) when true in [x>10,x<5,x==7] -> x end