[swift-evolution] modifying Array<Element> to return Element! when subscripted
sean at fifthace.com
Thu Jun 23 11:13:08 CDT 2016
If you’re resigned to checking for nil, then why not just check the index to make sure it is in bounds *before* fetching from the array in the first place?
> On Jun 23, 2016, at 11:07 AM, Pranjal Satija via swift-evolution <swift-evolution at swift.org> wrote:
> Would modifying array subscripts to return implicitly unwrapped optionals be a bad idea? This way, if an array is indexed out of bounds, the returned value will be nil, instead of a fatal error. This would allow developers to check for nil before fatal errors are created.
> swift-evolution mailing list
> swift-evolution at swift.org
More information about the swift-evolution