Fundamentals5 / 9
Up next

if as an expression

@main def main(): Unit =
  val n = 7
  // if/else is an expression, not a statement
  val parity = if n % 2 == 0 then "even" else "odd"
  println(parity)
What you're solving

if/else yields a value