[swift-evolution] For-loop revisited

Maximilian Hünenberger m.huenenberger at me.com
Tue Mar 8 12:13:27 CST 2016


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) { ... }

- Maximilian

> Am 08.03.2016 um 18:56 schrieb Антон Жилин <antonyzhilin at gmail.com>:
> 
> It's already possible:
> 
> for d in stride(from: 0, to: 5, by: 0.3) {
> }
> 
> Absolutely readable (despite all efforts to break it).
> And I would passionately hate the special syntax for floating-point loops in Swift.


More information about the swift-evolution mailing list