If ClosedRange (Range in Swift 2.2.1) has a stride(by:) method, we can change

stride(from: 0, to: 10, by: 3)

to

(0..<10).stride(by: 3)

and similarly, we can change

stride(from: 0, through: 10, by: 3)

to

(0…10).stride(by: 3)

As we can see, this syntax can replace both stride(from:to:by:) and 
stride(from:through:by:), and in my opinion it is more in line with the rest of 
Swift 3, similar to how Range.init(start:end:) will be deprecated in Swift 3 in 
favor of the … and ..< operators.

I’m not sure if this proposed stride(by:) method could replace all uses of 
stride(from:to:by:) and stride(from:through:by:), but I think that at the very 
least it would be a nice addition to the standard library.
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to