Created
October 11, 2020 21:02
-
-
Save deanwampler/98647681a702c13da41342bf51684915 to your computer and use it in GitHub Desktop.
Scala 2 vs. 3 optional control syntax changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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