Can anyone tell me why the code below works in Swift 2, but somehow breaks in Swift 3?
let range: Range = 0...2
However it can simply be fixed by doing this
let range: Range = 0..<3
Anyone knows what is the reason behind this?
Can anyone tell me why the code below works in Swift 2, but somehow breaks in Swift 3?
let range: Range = 0...2
However it can simply be fixed by doing this
let range: Range = 0..<3
Anyone knows what is the reason behind this?
Operators ...
and ..<
used to produce the same type, Range
, in Swift 2.x. Now they produce different types (migration guide):
Range
CountableRange
ClosedRange
CountableClosedRange
Changing the type in the first assignment to ClosedRange
should fix the problem. Better yet, let Swift infer the type for you:
let range = 0...2