I'm playing around with Swift extensions, and bumped my head against a strange bug, while trying to extend Bool:
typealias Task = ()->()
extension Bool{
func untilFalse(task: Task){
while !self {println(self); task()}
}
}
var i = 2
(i < 1).untilFalse{
println(i)
println("\(i) bottles of beer on the wall, \(i) bottles of beer.")
i--
println("Take one down and pass it around, \(i) bottles of beer on the wall.")
}
For some reason the loop just goes on and on, even after the boolean
expression has become true
.
Any ideas of what might be going on?