Summary
-
The
if
expression can be used to only perform an effect if a condition istrue
-
An
else
branch can be added to anif
to do something if the condition isfalse
-
You can build up more complex series of conditions with
if
/else if
/else
-
If you provide an
else
, and all branches evaluate to the same type, you can evaluate to a value from yourif
expression -
Functions can call themselves using recursion, which combined with conditionals, can allow for more sophisticated programs
-
Block-like expressions that evaluate to unit do not need a semicolon to be turned into statements
Get hands-on with 1200+ tech skills courses.