Maybe It’s There, Maybe It Isn’t: Optionals
A few times so far we’ve seen our log messages include the term “optional,” a behavior we’ve put off explaining until now. But it’s time to deal with it, because optionals are one of Swift’s defining features. Create a new playground called OptionalsPlayground and delete the "Hello, playground" line, as usual.
We’ll start by adding the sizeInMm dictionary from a few sections back, since that’s something that started giving us this “optional” stuff.
|||let sizeInMm = [|
|||"iPhone 6s": 138.1,|
|||"iPhone 6s Plus" : 158.1,|
|||"iPad Air 2" : 240.0]|
Looking at this, we can see that sizeInMm["iPhone 6s"] should evaluate to 138.1, which is a
Get iOS 9 SDK Development now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.