按照書(shū)本寫(xiě)了以下代碼,但貌似因?yàn)樗胹wift版本(我的環(huán)境是Xcode7.3)不同導(dǎo)致了一點(diǎn)語(yǔ)法錯(cuò)誤,沒(méi)有想到頭緒……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
//錯(cuò)誤2: Cannot assign to value: 'interestRate' is a 'let' constant
var interest = Double(years) * interestRate * loadAmmon
return loadAmmon + interest
}但是刪除了var之后會(huì)出現(xiàn)錯(cuò)誤2
- 2 回答
- 0 關(guān)注
- 1376 瀏覽
添加回答
舉報(bào)
0/150
提交
取消
