Implicitly unwrapped optional

Hi. I wonder why printed implicitly unwrapped optional is still surrounded by the parentheses and Optional? If its implicitly unwrapped, why does it not prints just the number? Many thanks.
Screenshot 2020-11-21 at 17.32.34

IOUs are only syntax sugar. They allow you to avoid writing ! every time you reference a property or pass it as a non-optional parameter, but it has no effect on the type. At runtime, the system has no idea it was defined using the IOU syntax.

2 Likes

thank You:)

Also in some cases the compiler will still interpret it as an Optional and needs to be dealt with.

If I recall correctly, I've usually seen this in cases where you're passing an IUO to some pure-Swift function or initializer that is expecting a non-optional value.

Terms of Service

Privacy Policy

Cookie Policy