for i in OpenRange(100, 110) { // 100 ..< 110
print(i)
}
for i in OpenRange(100, length: 10) { // 100 ..< 110
print(i)
}
for i in ClosedRange(100, 110) { // 100 ... 110
print(i)
}
for i in ClosedRange(100, length: 10) { // 100 ... 110
print(i)
}

Implementation

typealias OpenRange = Range
extension OpenRange {
init(_ from: Bound, _ to: Bound) {
self = from ..< to
}
}
extension OpenRange where Bound: AdditiveArithmetic {
init(_ from: Bound, length: Bound) {
self = from ..< from + length
}
}
extension ClosedRange {
init(_ from: Bound, _ to: Bound) {
self = from ... to
}
}
extension ClosedRange where Bound: AdditiveArithmetic {
init(_ from: Bound, length: Bound) {
self = from ... from + length
}
}