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

Optional types

In our day-to-day application development, we encounter situations where we expect to receive a value but we do not receive it. For instance, suppose that we have a list of items and we need to search for a particular value in the list. The particular value that we are looking for might not be on the list. Other examples can be calling a web service and receiving a JSON payload without the fields that we are looking for, or querying a database and not receiving the expected values.

What are we going to receive when the value is not there, and how will we handle this absence?

In programming languages such as C, it is possible to create a variable without giving it a value. If we try to use the variable before assigning a value, ...

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