# for i in 0...UInt8.max

**URL:** <https://forums.swift.org/t/for-i-in-0-uint8-max/4866>\
**Category:** Using Swift\
**Created:** [January 11, 2017, 1:06pm UTC](https://forums.swift.org/t/for-i-in-0-uint8-max/4866 "2017-01-11T13:06:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tuuranton](https://avatars.discourse-cdn.com/v4/letter/t/76d3ee/32.png) [@Tuuranton](https://forums.swift.org/u/Tuuranton)\
**Post date:** [January 11, 2017, 1:06pm UTC](https://forums.swift.org/t/for-i-in-0-uint8-max/4866/1 "2017-01-11T13:06:00Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![eskimo](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/eskimo/32/13558_2.png) [@eskimo](https://forums.swift.org/u/eskimo)\
**Post date:** [January 11, 2017, 3:12pm UTC](https://forums.swift.org/t/for-i-in-0-uint8-max/4866/2 "2017-01-11T15:12:11Z")

</div>

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&gt](https://developer.apple.com/reference/swift/closedrange&gt);

\<[https://developer.apple.com/reference/swift/countableclosedrange&gt](https://developer.apple.com/reference/swift/countableclosedrange&gt);

\<[https://developer.apple.com/reference/swift/range&gt](https://developer.apple.com/reference/swift/range&gt);

\<[https://developer.apple.com/reference/swift/countablerange&gt](https://developer.apple.com/reference/swift/countablerange&gt);

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/&gt](http://www.apple.com/developer/&gt);  
> Apple Developer Relations, Developer Technical Support, Core OS/Hardware
