[swift-evolution] Arrays Returning Optionals instead of Index Out of Bounds

Vladimir.S svabox at gmail.com
Thu Jun 23 09:14:35 CDT 2016

On 23.06.2016 15:48, Andreas Ley wrote:
>> Please find the related proposal which was formed after the long
>> discussion in the list:
>> https://github.com/luish/swift-evolution/blob/proposal-lenient-collection-subscripts/proposals/nnnn-more-lenient-collections-subscripts.md
> Thanks; I have seen this and other proposals, but none of them address
> the problem that most people don’t expect a crash when using

"..*most* people don’t expect.." could you prove this please? Perhaps you 
want to say *many* people. Probably. But the same many people expect this. 
Especially if they know a little of C language or other language that don't 
allow to use wrong indexes for arrays.

Also, why they don't expect this when writing in Swift? This behavior 
described in help/documentation/tutorial for Swift, this is how Swift works 
with arrays.

> subscripting – except for Erica’s excellent suggestion to make subscript
> throw, which would also require considerable changes to existing code.

I'm not sure about this idea. Still - if you'll use wrong index your 
program will crash by thrown exception. Or I don't understand the suggestion.

> - Andreas

More information about the swift-evolution mailing list