[swift-evolution] Arrays and Optionals

Sean Kosanovich sean7512 at me.com
Tue Dec 15 06:08:06 CST 2015


Hello all!

I have been using Swift nearly exclusively for iOS projects since its release (for better or worse).  I love the fact that a compiling application gives me some sort of guarantee that I won’t encounter a nil reference (unless of course I ignore optionals and force unwrap them…not a great idea).

When pulling values out of a Dictionary, we get an Optional value which makes perfect sense.  Why does this not extend out to Arrays?  There is no guarantee that when I am pulling the 8th element out, that it will have a valid value.

It seems odd to me that Optionals are a fundamental part of the language but they don’t extend to Arrays.

Thanks,
Sean


More information about the swift-evolution mailing list