<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><blockquote type="cite" class="">On 17 Mar 2016, at 14:48, nebulabox via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""></blockquote><div><blockquote type="cite" class=""><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="">I have several codes like the following:</div><div class=""><br class=""></div><div class="">for var i = 0; i &lt; myarr.count; i += n { // the step is NOT 1</div><div class="">&nbsp; &nbsp;// many codes</div><div class="">}</div><div class=""><br class=""></div><div class="">(…) If no C-style for loop, &nbsp;what's the best replacement for it ?</div></div></div></blockquote><br class=""></div><div>The stride is what you're looking for:</div><div><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div><font face="Menlo" class="">for i in <b class="">stride(from: 0, to: myarr.count, by: n)</b> {</font></div><div><font face="Menlo" class="">&nbsp; &nbsp; // ...</font></div><div><font face="Menlo" class="">}</font></div></blockquote><div><br class=""></div><div>In the current Swift release, you'd construct it like this though:</div><div><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div><div><font face="Menlo" class="">for i in <b class="">0.stride(to: myarr.count, by: n)</b> {</font></div></div><div><div><font face="Menlo" class="">&nbsp; &nbsp; // ...</font></div></div><div><div><font face="Menlo" class="">}</font></div></div></blockquote><div><div><br class=""></div><div>— Pyry</div><div class=""><br class=""></div></div></body></html>