This:
let x: Int = 4
creates an optional variable xand initializes it to 4. xcan be used without problems.
This:
let x: Int
// Cannot do anything with x yet
x = 4
creates an optional variable xwith no defined value . It cannot be used without first assigning it to a value either directly (as in your example) or the result of any other operator. If you try to use it, you will get a compile time error.
source
share