[swift-evolution] Feature proposal: Range operator with step

Dave Abrahams dabrahams at apple.com
Thu Apr 14 15:22:06 CDT 2016

on Thu Apr 14 2016, Hans Huck <swift-evolution at swift.org> wrote:

> Dave Abrahams via swift-evolution <swift-evolution at ...> writes:
>> If I thought extreme concision was important for this application, I'd be
>> proposing something like 
>>   for x in 0.0..<20.0//1.3 {}
>> but personally, I don't,
> And that is why exactly? The For-loop is at the very core of the language
> and one of its most frequently used structures. Any unnecessary noise should
> be avoided here.
>> which is why I propose `.striding(by: x)`
>> rather than simply `.by(x)`, the latter being more open to
>> misinterpretation.
> Please elaborate. How could
> for i in (1...10).by(3)
> possibly be misinterpreted?


Doesn't exactly tell me what role lineCount is playing or what "by"
does.  Maybe it means give me the range sorted by line count.  In this
case a little more verbosity can be the difference between
understandable and unmistakable.


More information about the swift-evolution mailing list