[swift-evolution] For-loop revisited

Dave Abrahams dabrahams at apple.com
Tue Mar 8 18:33:41 CST 2016


on Tue Mar 08 2016, Maximilian H├╝nenberger <swift-evolution at swift.org> wrote:

> Actually you cannot use the global stride function anymore.
> I thought a method on "Range" which returns a stride would be easier to grasp:
>
> for x in 0.stride(to: 0.5, by: 0.03) { ... }
>
> // much faster to predict what is does even though it is less clear to a beginner
> for x in (0 ... 0.5).by(0.03) { ... }

Frankly I find the free function to be much more readable than either of these.

-- 
-Dave



More information about the swift-evolution mailing list