Optional binding stores the value that you’re binding in a variable . 2. Optional chaining doesn’t allows an entire block of logic to happen the same way every time. 2. Optional binding allows an entire block of logic to happen the same way every time.
Read moreWhy are optional Swifts good?
Swift’s optionals are one of its most powerful features , while also being one of the most confusing. Their core job is simple: they allow us to represent the absence of some data – a string that isn’t just empty, but literally doesn’t exist.
Read moreWhat is optional chaining in Swift?
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 .
Read moreShould I use optional chaining?
You can use optional chaining when attempting to call a method which may not exist . This can be helpful, for example, when using an API in which a method might be unavailable, either due to the age of the implementation or because of a feature which isn’t available on the user’s device.
Read more