[swift-corelibs-dev] Bounds Checking on NSArray

Daniel Strokis dstrokis at icloud.com
Thu Dec 3 21:14:09 CST 2015


Hi all, 

In swift-corelibs-foundation/Foundation/NSArray.swift on line 347 there is a comment that says TODO: Bounds checking . Since that just call objectAtIndex, I think the bounds checking should be done inside of objectAtIndex. My question, though, is what should be returned if the index is out of the array bounds? The methods don’t throw, so I don’t think we can raise an exception. And I don’t think we can return nil because the method is supposed to return a non-optional AnyObject. What about using assert or precondition?

I’m super excited to be a part of this community!

Thanks,
Daniel Strokis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-corelibs-dev/attachments/20151203/11302615/attachment.html>


More information about the swift-corelibs-dev mailing list