+Optional chaining is a process for querying and calling properties, methods, and subscripts on an optional that might currently be nil. If the optional contains a value, the property, method, or subscript call succeeds; if the optional is nil, the property, method, or subscript call returns nil. Multiple queries can be chained together, and the entire chain fails gracefully if any link in the chain is nil. The `?` symbol is suffixed to the `Optional` variable to perform Optional Chaining. The benefit of this over Forced Unwrapping is that it doesn't throw error if `nil` is found. The result is always given as an `Optional`. Instead, it returns `nil` value. The following example shows Optional chaining using nested Tuples as we haven't seen about classes and structs in Swift.
0 commit comments