Swift 5.7’s new optional unwrapping syntax
A quick look at a new, more concise way to unwrap optional values that’s being introduced in Swift 5.7.
Articles, podcasts and news about Swift development, by John Sundell.
A quick look at a new, more concise way to unwrap optional values that’s being introduced in Swift 5.7.
Let’s explore how optional values work in Swift, including how they’re implemented under the hood, and what sort of techniques that we can use to handle them.
A really elegant aspect of Swift's take on optionals is that they're largely implemented using the type system - since all optional values are actually represented using an enum under the hood. That gives us some interesting capabilities, since we can extend that enum to add our own convenience APIs and other kinds of functionality. This week, let's take a look at how to do just that.
Even though Optionals are one of the most important features of Swift, sometimes they can put you in somewhat of a tight spot. Let's take a look at how to avoid those situations, and how to deal with non-optional optionals in a nice way.