[swift-evolution] Arrays Returning Optionals instead of Index Out of Bounds
andreas at ley.info
Thu Jun 23 09:52:57 CDT 2016
> "..*most* people don’t expect.." could you prove this please?
I should have written “most people I know” or “the people I work with".
> Especially if they know a little of C language or other language that don't allow to use wrong indexes for arrays.
Maybe that’s the point: They don’t. And it is my understanding that they shouldn’t need to; that Swift should be for everyone and a great language to get into programming.
> This behavior described in help/documentation/tutorial for Swift, this is how Swift works with arrays.
Yes, and I agree with you that people should read the documentation.
However, the question is: Is this behavior optimal? Is a runtime error really the best way to handle this for the most common use case of arrays?
But the definition of “most common use case” varies wildly. Hence my idea to have separate classes for separate needs.
In the end, what’s most important to me is to be able to have a consistent mental model. Something simple like: If I’m using classes called “unsafe” or exclamation marks, my app might experience runtime errors. That’s something the students I’ve taught could understand easily.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution