You want to use the parameter to call by name, I believe the following should be sufficient:
implicit def extendedBoolean(a : Boolean) = new {
def implies(b : => Boolean) = {
!a || b
}
}
Explanation:
b, , ; Scala , . implies ( ) , .
, - , , => Boolean. , , : " " .
Scala , , , . , while, : .
object TargetTest2 extends Application {
//type signature not too terribly mysterious
def whileLoop(cond: => Boolean)(body: => Unit): Unit =
if (cond) {
body
whileLoop(cond)(body)
}
//about as easy to use as a plain-old while() loop
var i = 10
whileLoop (i > 0) {
println(i)
i -= 1
}
}