On p. 123, the variable declaration:
makes no sense to me. I thought I was getting the hang of optionals until I read that line. After contemplating that line for awhile and then trying several code examples that just produced errors, I decided to check the docs:
[quote]Voice Attributes Keys
The following constants are keys for the dictionary returned by attributesForVoice:.
let NSVoiceIdentifier: String
let NSVoiceName: String
let NSVoiceAge: String
let NSVoiceGender: String
let NSVoiceDemoText: String
let NSVoiceLocaleIdentifier: String
let NSVoiceSupportedCharacters: String
let NSVoiceIndividuallySpokenCharacters: String
So the ! looks like errata.
Would it make sense for any let variable to be declared as an implicitly unwrapped optional? A let variable’s value cannot change, and if the let variable is an optional type then it can be initialized with nil, so forcibly unwrapping it(implicitly or explicitly) wouldn’t be safe. Contrast that with declaring a var as an implicitly unwrapped optional: the variable could be initialized with nil then changed to a non-nil value before we could interact with the variable, so declaring the var as an implictly unwrapped optional would be safe.