按照书本写了以下代码,但貌似因为所用swift版本(我的环境是Xcode7.3)不同导致了一点语法错误,没有想到头绪……
let simpleInterestCalculationClosure = { (loadAmmon : Double, var interestRate : Double, years : Int) -> Double in //警告1:'var' parameters are deprecated and will be remove in swift 3 fix-it Delete "var" interestRate = interestRate / 100.0 //错误2: Cannot assign to value: 'interestRate' is a 'let' constant var interest = Double(years) * interestRate * loadAmmon return loadAmmon + interest }
但是删除了var之后会出现错误2
Qyouu
哈士奇WWW