[swift-users] Bug? Bad behaviour?

Maury Markowitz maury.markowitz at gmail.com
Fri Dec 2 12:28:05 CST 2016

Check out this line of code:

if parts[2].characters.count > 0 { data["I3"] = Int(parts[2]) }

This worked fine in 2.x, but in 3.0 it complains:

Cannot subscript a value of type 'inout [String]' (aka 'inout Array<String>')

It took me a *long* time before I consider that the error was incorrect and found this trivial solution:

if c > 0 && parts[0].characters.count > 0 { data["I1"] = Int(parts[0]) as NSNumber? }

So, is this a "bug"? The error has nothing to do with indexing, it seems. But maybe I'm wrong?

More information about the swift-users mailing list