scastie icon indicating copy to clipboard operation
scastie copied to clipboard

Multiple lines of code after an if comparison doesn't work as expected

Open pishen opened this issue 1 year ago • 1 comments

According to the official Scala 3 book, this should be a valid syntax:

val x = 1

if x == 1 then
  println("x is 1, as you can see:")
  println(x)
else
  println("x was not 1")

But pasting this in Scastie will get an error "end of statement expected but 'else' found" https://scastie.scala-lang.org/iJkk0GGTQt6sMwz2cgf2Cg

Screenshot 2023-06-26 at 8 49 53 AM

pishen avatar Jun 26 '23 00:06 pishen

Hey, thanks for reporting. The new syntax braceless is not yet supported by worksheet mode. It is going to change in the near future. If you run this snippet without worksheet mode, it should properly compile.

rochala avatar Jun 26 '23 06:06 rochala