0

Hello I am using swift and when I am trying to use and increment it outputs a pair of parenthesis.

var initialScore = 8
let TotalScore = initialScore+=1

The error comes out as

Constant 'TotalScore' inferred to have type '()', which may be unexpected

Please help me!

1 Answers1

0

You have small issue that is connected with =. To solve youre problem try :

var initialScore = 8
let TotalScore = initialScore+1

If you would like to increment value by 1 you should not use = before 1 in you're case.

Small example where you should use += together.

var a = 1
a += 2
Oleg Gordiichuk
  • 15,240
  • 7
  • 60
  • 100