I'm looking at Swift 3.0.1 now. This code works fine:
for i in 0..<UInt8.max { print(i)}
And so does this code:
for i in 0...UInt8.max { print(i)}
These codes used to crash in earlier Swifts. Can you explain why? What changed in the meantime? It had something to do with the range overflow at UInt8.max.
We now have the notion of `ClosedRange`, which can represent all values in an integer type (at the cost of introducing the complexity of two different range types).
You can find a bunch of info about this at the following links.
<https://developer.apple.com/reference/swift/closedrange>
<https://developer.apple.com/reference/swift/countableclosedrange>
<https://developer.apple.com/reference/swift/range>
<https://developer.apple.com/reference/swift/countablerange>
Share and Enjoy
···
On 11 Jan 2017, at 13:06, tuuranton--- via swift-users <swift-users@swift.org> wrote:
These codes used to crash in earlier Swifts. Can you explain why?
--
Quinn "The Eskimo!" <http://www.apple.com/developer/>
Apple Developer Relations, Developer Technical Support, Core OS/Hardware