iOS Swift Basics Swift Types Recap: Swift Types

Need quick help

why isn't this working

let firtValue:var = 1
let secondValue:var = 2

Hi Raz, first you declared a constant with let, added the name firstValue or secondValue, you need to add the type. Adding the type first add (:) space and Type. in this case your type is Int. Solution: let firstValue: Int = 1 let secondValue: Int = 2

1 Answer

13,433 Points

There are three errors here. First, the first value constant is spelled firstValue. Next you have declared the constant firstValue's type as a variable, which is not even a type. It is not necessary to declare these constant values' types, but if you were then the numbers 1 and 2 are integers. The correct code would be :

let firstValue: Int = 1
let secondValue: Int = 2