[swift-dev] C-style For Loops

Wallacy wallacyf at gmail.com
Sat Dec 19 19:27:52 CST 2015


>
> Why?
>


Because this works:

var rangeA = -150.0..<150
for lat in rangeA.by(30) {
    print(lat)
}

And this not:

var rangeC = -150..<150
for lat in rangeC.by(30) { // Error - Value of type 'Range<Int>' has no
member 'by'
    print(lat)
}

I think this is expected to work, or not?

If you make a extension for "Range" will work of course.



> I don't understand most of what you're saying here, or why you're saying
> it.  The extensions as shown in Donnacha's post work for me.
>
>
>
Not a big deal, just saying I think weird call "startIndex" and "endIndex"
on "Range", because on (HalfOpen|Close)Interval are only "start" and "end".

Also is weird the existence of the 3 types for basically the same purpose.

But is not the point of this topic of course.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-dev/attachments/20151220/925dd4c7/attachment.html>


More information about the swift-dev mailing list