Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Scala 2 vs. 3 optional control syntax changes.
for (i <- 0 until 5) println(i) // Original syntax
for i <- 0 until 5 do println(i) // New syntax
for i <- 0 until 5 yield 2*i
for i <- 0 until 10
if i%2 == 0
ii = 2*i
yield ii
val i = 10
if (i < 10) println("yes") // Original syntax
else println("no")
if i < 10 then println("yes") // New syntax
else println("no")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.