The Scala compiler will not infer semicolons while inside parentheses. That's why it is advantageous to use curly braces, because you can leave off some of the semicolons that are needed when you use parentheses.
The following code will be successfully compiled:
for (
i1 <- 1 to 5
if i1 % 2 == 0;
i2 <- 1 to i1
if i2 > 2
) println(i2)
Login in to like
Login in to comment