Skip to content

Instantly share code, notes, and snippets.

@deanwampler
Last active November 18, 2020 13:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deanwampler/6c7124e65102e4c203a47127fa329716 to your computer and use it in GitHub Desktop.
Save deanwampler/6c7124e65102e4c203a47127fa329716 to your computer and use it in GitHub Desktop.
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