I just upgraded my project to Swift 3 from 2.3. All my loops are endless. I can play it on a fresh playground:
That's what I'm doing:
var strs = [String!]() strs.append("hello") strs.append("world") var count = 0 for s in strs { count += 1 }
What's wrong? On the playground, the cycle runs continuously.
Looking at Apple's docs, this one should work, right?
UPDATE : If I change the definition of the array as follows, it will work as expected. What is the harm in forcing optional values ββin an array?
var strs = [String]()
UPDATE 2 : This is a known bug - https://bugs.swift.org/browse/SR-1635
source share