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

Unwrapping optionals

So far, we know that Optionals wrap values in themselves. Wrapping means that the actual data is stored within an outer structure or container (See Higher-kinded types in the previous chapter).

For instance, we print optionalString as follows:

print(optionalString) 

The result will be Optional("A String literal").

How will we unwrap Optionals and use the values that we need? There are different methods to unwrap Optionals that we will go through in the following sections.

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