From Apple’s documentation:
You can use
if
andlet
together to work with values that might be missing. These values are represented as optionals. An optional value either contains a value or containsnil
to indicate that the value is missing. Write a question mark (?
) after the type of a value to mark the value as optional.
Why would you want to use an optional value?