Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialMike Zhu
1,840 PointsAsking question about three dots "..." and two dots ".." in the range of programming language
Now I am quite struggle about the range, what is the difference between the three dots like, ... and two dots like, .. in a kind of range between two integers.
Such as: UInt32(50)...UInt32(200) and UInt32(50)..UInt32(200)
Basically it is a swift project.
1 Answer
Timothy OBrien
2,832 PointsHey Mike,
Swift has two Range Operators - the first one is 3 period characters (...) and creates ranges that run from a to b (including both a and b in the range)
Example:
var a = 10
var b = 12
let range = a...b // includes integers 10,11 and 12
The second type of Swift range uses the ..< operator and runs from a to b but does not include b in the range
Example:
var a = 10
var b = 12
let range = a..<b // includes integers 10 and 11 only
I suggest pasting the examples into a Playground in Xcode - you should be able to then inspect the values of each range type.
Hope this helps!
Tim