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

Brandon Knope bknope at me.com
Thu Apr 14 20:12:02 CDT 2016


What about "strideby"

Brandon 

> On Apr 14, 2016, at 8:57 PM, Hans Huck via swift-evolution <swift-evolution at swift.org> wrote:
> 
> Erica Sadun via swift-evolution <swift-evolution at ...> writes:
>> 
>> 
>>> On Apr 14, 2016, at 1:42 PM, Hans Huck via swift-evolution
> <swift-evolution <at> swift.org> wrote:
>>> Please elaborate. How could
>>> 
>>> for i in (1...10).by(3)
>>> 
>>> possibly be misinterpreted?
>> 
>> (1..<11), (4..<14), (7..<17)...
> 
> Or (3..<30)? :)
> 
> With that reasoning, "for in" would have to be changed to "for each" to
> avoid possible misinterpretation; after all, "i" could be a range and "for i
> in" could test if it's a subrange of (1...10).
> 
> Basically, there is no such thing as "unmistakable", not least because the
> very same keywords and symbols are being used for different purposes in
> different languages. There are only degrees of clarity.
> 
> Anyway, why not just make it .step() then, like in Ruby?
> 
> Instead of a "by" keyword, I'd be happy with syntactic sugar in the form of
> 
> for i in p1..<p2 step x
> 
> too, btw.
> 
> -- Hans
> 
> 
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution


More information about the swift-evolution mailing list