Question
What value does an if expression return?
Select an option. Your answer will be checked instantly.
Correct Answer: B. The value produced by the selected branch
Explanation:
Scala's if is an expression rather than only a control statement.
Both branches can contribute to the inferred result type.
Leave a Reply