I suggest dropping this near "if as an expression" in Control structures
- if construct becomes (will be inferred) as expression only if all ways of logic will finish with some value. If without else will be treated as a statement. And as such will not produce expected behavior, even in the case when if condition is true:
Try this code:
val c1 = if 4>=3 then "bingo!" else "nope!"
println(c1.getClass)
val c2 = if 4>=3 then "bingo!"
println(c2.getClass)
Result:
class java.lang.String
void