<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="">Let me add that stride offers two variations: "to" and "through", which you can see here:&nbsp;<div class=""><a href="http://swiftstub.com/102043338" class="">http://swiftstub.com/102043338</a><div class=""><br class=""></div><div class="">The to variation documentation states:</div><div class=""><br class=""></div><div class=""><div class="">&nbsp; &nbsp; /// Return the sequence of values (`self`, `self + stride`, `self +</div><div class="">&nbsp; &nbsp; /// stride + stride`, ... *last*) where *last* is the last value in</div><div class="">&nbsp; &nbsp; /// the progression that is less than `end`.</div></div><div class=""><br class=""></div><div class="">The through variation:</div><div class=""><br class=""></div><div class=""><div class="">&nbsp; &nbsp; /// Return the sequence of values (`start`, `start + stride`, `start +</div><div class="">&nbsp; &nbsp; /// stride + stride`, ... *last*) where *last* is the last value in</div><div class="">&nbsp; &nbsp; /// the progression less than or equal to `end`.</div><div class="">&nbsp; &nbsp; ///</div><div class="">&nbsp; &nbsp; /// - Note: There is no guarantee that `end` is an element of the sequence.</div></div><div class=""><br class=""></div><div class="">-- E</div><div class=""><br class=""></div><div class=""><div class=""><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 15, 2015, at 1:14 AM, Jacob Bandes-Storch via swift-users &lt;swift-users@swift.org&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" style="font-family: Palatino-Roman; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">You can use `stride`:<div class=""><br class=""></div><div class="">for i in 0.stride(to: 10, by: 2) {</div><div class="">&nbsp; &nbsp; print("i is \(i)")</div><div class="">}</div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Tue, Dec 15, 2015 at 12:08 AM, Eirny Kwon via swift-users<span class="Apple-converted-space">&nbsp;</span><span dir="ltr" class="">&lt;<a href="mailto:swift-users@swift.org" target="_blank" class="">swift-users@swift.org</a>&gt;</span><span class="Apple-converted-space">&nbsp;</span>wrote:<br class=""><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><div style="word-wrap: break-word;" class=""><div style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;" class=""><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: 'Meslo LG M DZ';" class=""><span style="font-family: Helvetica, Arial; font-size: 13px;" class="">for loop is working</span></div><div class=""><span style="font-family: Helvetica, Arial; font-size: 13px;" class=""><br class=""></span></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: 'Meslo LG M DZ';" class=""><span style="color: rgb(187, 44, 162);" class="">for</span><span class="Apple-converted-space">&nbsp;</span><span style="color: rgb(187, 44, 162);" class="">var</span><span class="Apple-converted-space">&nbsp;</span>i =<span class="Apple-converted-space">&nbsp;</span><span style="color: rgb(39, 42, 216);" class="">0</span>; i &lt;<span class="Apple-converted-space">&nbsp;</span><span style="color: rgb(39, 42, 216);" class="">10</span>; i +=<span class="Apple-converted-space">&nbsp;</span><span style="color: rgb(39, 42, 216);" class="">2</span><span class="Apple-converted-space">&nbsp;</span>{</div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: 'Meslo LG M DZ'; color: rgb(209, 47, 27);" class=""><span style="" class="">&nbsp; &nbsp;<span class="Apple-converted-space">&nbsp;</span></span><span style="color: rgb(61, 29, 129);" class="">print</span><span style="" class="">(</span>"i is<span class="Apple-converted-space">&nbsp;</span><span style="" class="">\</span>(<span style="" class="">i</span>)"<span style="" class="">)</span></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: 'Meslo LG M DZ';" class="">}</div><div class=""><br class=""></div></div><div class=""><div class=""><div class="h5"><br class=""><div class=""><div style="font-family: helvetica, arial; font-size: 13px;" class=""><span style="font-family: Helvetica, Arial;" class="">On December 15, 2015 at 5:05:41 PM, cooper liu via swift-users (</span><a href="mailto:swift-users@swift.org" target="_blank" style="font-family: Helvetica, Arial;" class="">swift-users@swift.org</a><span style="font-family: Helvetica, Arial;" class="">) wrote:</span></div></div></div></div><blockquote type="cite" class=""><span class=""><div class=""><div class=""></div><div class=""><div class=""><div class="h5"><div class="">Hi,</div><div class="">If the c style for loop was removed,how to implement the following code beautifully:</div><div class="">For(var i=0; i &lt; 10; i+=2)</div><div class="">Since the range operator ... doesn't support step other than 1, and it doesn't support end value &lt; start value.</div><div class=""><br class=""></div><div class="">Thanks!</div><div class=""><div class=""><br class=""></div><br class=""></div></div></div><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=9xi1sqmKsCg9jKqAWTVX7BM9IbeqCt5n-2Bct01Y2bp-2FRexUSd2DSiI0VaQbhYV4Lvbl16Hy1FcaAl7HyjIb-2FV6GiqJCQ7m7vYrlByAx6CUIijFPKMOByg5311uGucL9fMWtisSdkHYLoox4uhWb55G9VnXjdi0VBjlrQUap73MFtZ8-2BkozrGuoKdATOeJpU-2BjCO008DNbd2XUbH4isRW6NNvzxiTLiLYJR8N81H66Acg-3D" alt="" width="1" height="1" border="0" style="min-height: 1px !important; width: 1px !important; border-width: 0px !important; margin: 0px !important; padding: 0px !important;" class=""><span class="Apple-converted-space">&nbsp;</span>_______________________________________________<br class="">swift-users mailing list<br class=""><a href="mailto:swift-users@swift.org" target="_blank" class="">swift-users@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-users" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-users</a><br class=""></div></div></span></blockquote></div><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=P-2BsYbBZHRBuLDBJaL4DIKDNfkkjpROowTyRAObV11qy63Krvu9-2BIuVKT8Pc88CDU3FPuRlOMeORhea6rqTX5RQlR6osxfyymW-2F4d2afxfamqdPGiMERGuhoDkbDFEh3GbxwBKRGtvIcgn8BEitLuC1ZA5uG3ZlM33SQW8YYpKFGkAmdtw3xVsaGgoQzjYKOO6QQzvyTNfP5VloCMdw9LYRivumox4T664nl710FjStE-3D" alt="" width="1" height="1" border="0" style="min-height: 1px !important; width: 1px !important; border-width: 0px !important; margin: 0px !important; padding: 0px !important;" class=""></div><br class="">_______________________________________________<br class="">swift-users mailing list<br class=""><a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-users</a><br class=""><br class=""></blockquote></div><br class=""></div></div><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=r5jpKsi6nat7oa43lpCLi5GRGm2utDkbDscuFklXZ2dSuloeWTpUJb0A0STLsjQVL8jJjMZpU4-2FyT8ThonFPdXEWcoiXBykot-2FB-2B6EPIMUH69nhBbhPzgthVnpy6U2NznXTmo45vQz-2BEkTM0VgJje8iTPxBqcfNW6s-2FZnw-2FpgoXpu2WBHcRSt-2B6QGQOT-2Br-2F5hvpg16TcWPs-2BL-2B49qGTUxhSfZS6E8VtcC3KP-2BBwxwlM-3D" alt="" width="1" height="1" border="0" style="font-family: Palatino-Roman; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; height: 1px !important; width: 1px !important; border-width: 0px !important; margin: 0px !important; padding: 0px !important;" class=""><span style="font-family: Palatino-Roman; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class=""><span class="Apple-converted-space">&nbsp;</span>_______________________________________________</span><br style="font-family: Palatino-Roman; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Palatino-Roman; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">swift-users mailing list</span><br style="font-family: Palatino-Roman; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="mailto:swift-users@swift.org" style="font-family: Palatino-Roman; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">swift-users@swift.org</a><br style="font-family: Palatino-Roman; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="https://lists.swift.org/mailman/listinfo/swift-users" style="font-family: Palatino-Roman; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">https://lists.swift.org/mailman/listinfo/swift-users</a></div></blockquote></div><br class=""></div></div></div></div></body></html>