When is semicolon mandatory in scala?
问题 I am learning how to program in Scala and was being told that semicolon is optional in Scala. So with that in mind, I tried with the following nested block of code which does not have semi colon. However, it throws an error in the Scala REPL scala> { val a = 1 | {val b = a * 2 | {val c = b + 4 | c} | } | } <console>:17: error: Int(1) does not take parameters {val b = a * 2 And the sample with semi colon worked perfectly fine. scala> { val a = 1; | { val b = a*2; | { val c = b+4; c} | } | }