Last active
November 18, 2020 13:33
-
-
Save deanwampler/6c7124e65102e4c203a47127fa329716 to your computer and use it in GitHub Desktop.
Scala 3 braceless syntax and user-defined controls?
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
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