<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=""><div class="">I’m behind the idea in principle, but I’m not so sure we need a new keyword for this:</div><div class=""><br class=""></div><div class=""><font face="Monaco" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>for eachIndex in (1 ..< 10).by(2) { … }</font></div><div class=""><br class=""></div><div class="">The above would be adequate I thin, and just requires a new method on ranges and similar types. This is being discussed, among other things, in the c-style for loop discussion, as these were recently removed but without a replacement for this type of use-case.</div><br class=""><div><blockquote type="cite" class=""><div class="">On 23 Mar 2016, at 21:40, David Knothe via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi,<div class=""><br class=""></div><div class="">I am new to Swift mailing list so I don’t know if this topic has already been discussed.<br class=""><div class=""><br class=""></div><div class="">I like Swift's range operators ..< and …</div><div class="">What I am missing though is an easy operator to create a range with a specified step. Currently, if you would want to iterate over some odd numbers, you had to write:</div><div class=""><i class="">for i in 1.stride(through: 7, by: 2) { … }</i></div><div class="">What I think would be simpler and more convenient would be something like the following:</div></div><div class=""><i class="">for i in 1 … 7 step 2 { … } . </i>Another option would be <i class="">for i in 1 … 7; 2 { … }</i></div><div class="">The keyword ‚step‘ in this context clearly corresponds to the step of the range to create or to iterate over.</div><div class=""><br class=""></div><div class="">Essentially this is a syntactic sugar that makes it easy to create ranges with a step ≠ 1. What do you think?</div></div>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></body></html>