Truth And Controls
Section
nil
Flow Of Control
x = 10
y = 10
x
10
if x > 9 do
"it's true"
end
"it's true"
if x > 10 do
"it's true"
else
"it's false"
end
"it's false"
result =
cond do
x > 15 -> "so very hot"
x > 10 -> "a little hot"
true -> "whatever"
end
"whatever"
result
"whatever"
answer =
case x > 10 do
# pattern -> thing-to-execute
true -> "it's true"
# _ -> wild card, match everything
_ -> "it's false"
end
"it's false"
looks_safe =
case do_something_dangerous() do
{:ok, result} -> result
error -> error
end
error: undefined function do_something_dangerous/0 (there is no such import)
#cell:24o7ojgnyveydlfllt5fc3pttzvnt74n:2