@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()
}
Asked
Active
Viewed 2,159 times
-2

David Rönnqvist
- 56,267
- 18
- 167
- 205

Farras Doko
- 307
- 4
- 11
1 Answers
6
You should use use score = score + 1
instead of score++

Zee
- 327
- 1
- 8
-
5The recommended replacement is `score += 1` – vadian Oct 20 '17 at 10:16
-
yes you are right @vadian but score = score + 1 easy for learning purpose – Zee Oct 20 '17 at 10:21
-
No, learn the right stuff. Who is able to understand `++` will understand `+= 1`, too ;-) – vadian Oct 20 '17 at 10:24
-
okay sir you right! – Zee Oct 20 '17 at 10:26