[swift-evolution] For-loop revisited

Dave Abrahams dabrahams at apple.com
Tue Mar 8 18:32:29 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.

It's coming back; never fear.

> 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.
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

-- 
-Dave



More information about the swift-evolution mailing list