This is a bit confusing, but the value in the Dictionary already optional, so the value is optional:
let optionalInts: [Int: Int?] = [ 0: 0 ]
Is redundant, making a double-optional value similar to:
let doubleOptionalInt: Optional<Optional<Int>> = 0
So what you need to do is discard the option:
let optionalInts: [Int: Int] = [ 0: 0 ]
Perhaps (or maybe not) surprisingly, you can recursively specify options unlimitedly:
let wayTooManyOptionalsInt: Int?????????????? = 0
And it will take the same amount ! to deploy it back to Int :
let backToInt: Int = wayTooManyOptionalsInt!!!!!!!!!!!!!!
Jerad Rose Apr 17 '15 at 6:36 2015-04-17 06:36
source share