return backwards ? stepBackward : stepForward
}
var currentValue = -4
let moveNearerToZero = chooseStepFunction(currentValue > 0)
// moveNearerToZero now refers to the nested stepForward() function
while currentValue != 0 {
println((currentValue)... )
currentValue = moveNearerToZero(currentValue)
}
println(zero!)
// -4...
// -3...
// -2...
// -1...
// zero!
?
本章由CocoaChina的翻译小组成员 Da杯柠檬水(微博)翻译,转载请注明出处和译者信息,拒绝商业之用。