-3
@IBAction func blueBtnAct(_ sender: AnyObject) {
score++ //error bcause Unary operator '++' cannot be applied to an operand of type '@lvalue Int'
blueLbl.text = "\(score)"
GrenLbl.text = "\(score)"
testScore()
}
@IBAction func GrenBtnAct(_ sender: AnyObject) {
score-- //error bcause Unary operator '--' cannot be applied to an operand of type '@lvalue Int'
blueLbl.text = "\(score)"
GrenLbl.text = "\(score)"
testScore()
}
的推荐替代使用
score = score + 1
是'得分+ = 1' – vadian是你right @vadian但是score = score + 1易于学习 – Zee
不,学习正确的东西。谁能理解'++'也会理解'+ = 1' ;-) – vadian