Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Scala 3 braceless syntax and user-defined controls?
import scala.annotation.tailrec
@tailrec def loop(whileTrue: => Boolean)(f: => Unit): Unit =
f
if (whileTrue) loop(whileTrue)(f)
var i=5
loop(i > 0) {
println(i)
i -= 1
}
var j=5
loop(j > 0): // ERROR
println(j)
j -= 1
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.