Swift 属性 函数(五)

2015-07-24 06:28:42 · 作者: · 浏览: 94
  • 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杯柠檬水(微博翻译,转载请注明出处和译者信息,拒绝商业之用。