0

Consider these two declarations:

var implicitUnwrappedOptionalInt: Int! = nil

var optionalInt: Int? = nil

The result would be nil in both the cases. So what is the difference?

Rob
  • 415,655
  • 72
  • 787
  • 1,044
vikash1307
  • 272
  • 2
  • 12
  • 3
    This similar question will suffice: http://stackoverflow.com/questions/24006975/why-create-implicitly-unwrapped-optionals – Khundragpan Jul 21 '16 at 06:04

1 Answers1

0

An implicitly unwrapped optional can be (will be) initialized nil BUT you are telling the compiler that it will be set to a value before you first use it. If you do try and use it before it is initialized like I do below, you will crash everytime.

enter image description here

Price Ringo
  • 3,424
  • 1
  • 19
  • 33