Cond
Useful to make multi conditions with different values and return the first that match true
This is equivalent to else if
clause in many imperative languages (used much less here)
Is necessary add a final condition equal true
, which always will match, because if all the conditions return nil
of false
an error CondClauseError
is raised
cond
considers any value besides nil
or false
to be true
If/Unless
Elixir provide macros if/2
and unless/2
which are useful when you need to check for only on condition
if
unless
They also support else
do/end
blocks
These are equivalent:
code/1
code/2
out/all
13
referencies
Elixir Conditions: https://elixir-lang.org/getting-started/case-cond-and-if.html [archive]