In some script language (like Perl or Ruby), we can use `0..3` or `0...3` to create a range. It gives a range from X to Y and steps by 1. This feature is warmly welcomed since it appears. It is not strange at all that Swift takes this syntax as well.

By specifying numbers on both sides of `...`, we can get a closed range. For example, `0...3` means a range from 0 to 3, including 3. More often we may need a range not containing the last number (for example we are trying to access by index of an array), then we can use `0 ..< 3` to get such a range. It is a little strange at the first glance, but in my opinion it expresses cleaner than `0 .. 3` in my opinion -- a "less than" sign tells the fact very well.

We can access this number range with a `for...in`:

``````for i in 0...3 {
print(i)
}

//Output: 0123
``````

If you think that's all about `...` and `..<`, you are definitely wrong. We can have a careful look at the definition of these two operators in Swift:

``````/// Forms a closed range that contains both `minimum` and `maximum`.
func ...<Pos : ForwardIndexType>(minimum: Pos, maximum: Pos)
-> Range<Pos>

/// Forms a closed range that contains both `start` and `end`.
/// Requres: `start <= end`
func ...<Pos : ForwardIndexType where Pos : Comparable>(start: Pos, end: Pos)
-> Range<Pos>

/// Forms a half-open range that contains `minimum`, but not
/// `maximum`.
func ..<<Pos : ForwardIndexType>(minimum: Pos, maximum: Pos)
-> Range<Pos>

/// Forms a half-open range that contains `start`, but not
/// `end`.  Requires: `start <= end`
func ..<<Pos : ForwardIndexType where Pos : Comparable>(start: Pos, end: Pos)
-> Range<Pos>

/// Returns a closed interval from `start` through `end`
func ...<T : Comparable>(start: T, end: T) -> ClosedInterval<T>

/// Returns a half-open interval from `start` to `end`
func ..<<T : Comparable>(start: T, end: T) -> HalfOpenInterval<T>
``````

All of them support generic. So what? Except for `Int` or `Double`, we can also put a `Comparable` in both sides, and expect a `ClosedInterval` or `HalfOpenInterval` as the returned value. `String` is a well-known type conforming `Comparable`. That means we can concat two strings with this operator and get a range. Here is an example of using it, we can check whether all characters in a word are lower case or not:

``````let test = "helLo"
let interval = "a"..."z"
for c in test {
if !interval.contains(String(c)) {
print("\(c) is not lower case.")
}
}

// Output:
// L is not lower case.
``````

Similar to the example above, we can check whether a character is ASCII by using `...`. Make a `ClosedInterval` of `\0...~`, then just compare it with your input. (`\0` and `~` are the first and last character respectively in ASCII).