Note: this post is part of a series about the Swift programming language, introduced at WWDC 2014. I’m no more experienced in Swift than anyone else outside Apple, but I learn best by coding and talking through a problem. If there’s a better way to approach some of these topics, get in touch on Twitter!
We’ve had a little over two weeks to play with the Swift programming
language now, and one sharp edge that keeps coming up is the
language’s inclusion of what they call “optional types”. The vast majority of
Objective-C developers are familiar with the use of
nil to indicate a
nonexistent value, but communicating that kind of information through a
variable’s type is a bit more foreign.
In this post, we’ll have an introductory discussion about how Swift provides optional types, go over a couple of implementation details, and point out a few tough spots in the optional system.Read on →