[swift-evolution] What's the best replacement if "Remove C-style for loops"?

nebulabox nebulabox at gmail.com
Thu Mar 17 07:48:43 CDT 2016


I have several codes like the following:

for var i = 0; i < myarr.count; i += n { // the step is NOT 1
   // many codes
}

I knew I could use the while loop, but it seems very ugly.
var i = 0
while i < marr.count {
    // some codes

    i += n   // Sometimes it is easy to be missed
}


If no C-style for loop,  what's the best replacement for it ?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160317/de2a57c3/attachment.html>


More information about the swift-evolution mailing list