O'Reilly logo

Swift Functional Programming - Second Edition by Dr. Fatih Nayebi

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Implicitly-unwrapped optionals

We can define implicitly-unwrapped Optionals by appending an exclamation mark (!) to the end of the type. These types of Optionals will unwrap themselves.

The following example presents two ways to get a value from a dictionary. In the first example, the resulting value will be an optional so should be unwrapped. The second example will implicitly unwrap the value:

Like forcefully unwrapping, implicitly-unwrapped Optionals may cause runtime crashes in our applications, so we need to be cautious when we use them.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required