<div id="compose" contenteditable="true" style="padding-left: 16px; padding-right: 16px; padding-bottom: 8px;">-1 for me. I don't think it's in the direction of Swift, it also gives little benefit to the standard library, I don't think I would have used it. In terms of verbosity, "repeat 5" is more readable to me than "someArray.times"</div><div id="compose" contenteditable="true" style="padding-left: 16px; padding-right: 16px; padding-bottom: 8px;"><br></div>
<div class="gmail_quote">_____________________________<br>From: Cihat Gündüz <<a dir="ltr" href="mailto:swift-evolution@swift.org" x-apple-data-detectors="true" x-apple-data-detectors-type="link" x-apple-data-detectors-result="0">swift-evolution@swift.org</a>><br>Sent: Saturday, January 9, 2016 8:53 PM<br>Subject: Re: [swift-evolution] Proposal: Add .times method to Integer type<br>To: Stephen Celis <<a dir="ltr" href="mailto:stephen.celis@gmail.com" x-apple-data-detectors="true" x-apple-data-detectors-type="link" x-apple-data-detectors-result="3">stephen.celis@gmail.com</a>><br>Cc: Davide De Franceschi via swift-evolution <<a dir="ltr" href="mailto:swift-evolution@swift.org" x-apple-data-detectors="true" x-apple-data-detectors-type="link" x-apple-data-detectors-result="4">swift-evolution@swift.org</a>><br><br><br> <meta content="text/html charset=utf-8"> Just an update to my thoughts about the times method in the meantime: <div class=""> <br class=""> </div> <div class=""> Currently I’m using my <a href="https://github.com/Flinesoft/HandySwift" class="">HandySwift</a> framework to include a `.times` method for my own usage and I’m happy that way for now – although that solution doesn’t allow for control flow statements. I still think it is a useful feature to be added to the language but I also agree with Chris that `repeat` should be in the name somewhere, so speaking about the syntax the following would be <b class="">my new proposal</b>: </div> <div class=""> <br class=""> </div> <div class=""> `repeat 5 times { /* code */ }` </div> <div class=""> <br class=""> </div> <div class=""> Also somebody here asked for <b class="">use cases</b> and here’s one from the HandySwift framework where I implemented it itself ( <a href="https://github.com/Flinesoft/HandySwift/blob/develop/Sources/Extensions/ArrayExtension.swift" class="">source</a>): </div> <div class=""> <br class=""> </div> <div class=""> <div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(187, 44, 162);" class=""> public <span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span>extension <span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span> <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Array</span> <span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> {</span> </div> <div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">public</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">var</span> sample: <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Element</span>? { </div> <div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">get</span> { </div> <div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">if</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">self</span>. <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">count</span> > <span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">0</span> { </div> <div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span> randomIndex = <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">self</span>.startIndex.advancedBy( <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Int</span>(randomBelow: <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">self</span>.count)) </div> <div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">return</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">self</span>[randomIndex] </div> <div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""> } </div> <div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">return</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">nil</span> </div> <div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""> } </div> <div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""> } </div> <p style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""> <br class="webkit-block-placeholder"></p> <div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">public</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">func</span> sample(size size: <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Int</span>) -> [ <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Element</span>]? { </div> <div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">if</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">self</span>. <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">count</span> > <span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">0</span> { </div> <div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">var</span> sampleElements: [ <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Element</span>] = [] </div> <div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""> size.times { // <== <== <== <== <== times method used here <== <== <== <== <== </div> <div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""> sampleElements.append( <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">self</span>.sample!) </div> <div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""> } </div> <div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">return</span> sampleElements </div> <div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""> } </div> <div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">return</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">nil</span> </div> <div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""> } </div> <div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""> } </div> </div> <div class=""> <br class=""> <div> <blockquote class=""> <div class=""> Am 21.12.2015 um 17:00 schrieb Stephen Celis via swift-evolution < <a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>>: </div> <br class="Apple-interchange-newline"> <div class=""> <meta content="text/html charset=utf-8" class=""> <div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""> <div class=""> Just another -1. While I appreciated it in Ruby, I don't think it belongs in the Swift standard library at this time. If closures could be annotated as break/continue-able, and if the standard library started grew a lot—as Ruby's did—then maybe (I'd prefer the former and hold off on the latter, though). </div> <div class=""> <br class=""> </div> <div class=""> In the meantime, "repeat 5 { /* do something */ }" seems better to me. </div> <div class=""> <br class=""> </div> <div class=""> Stephen </div> <br class=""> <div class=""> <blockquote class=""> <div class=""> On Dec 20, 2015, at 9:32 PM, T.J. Usiyan 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=""> <div dir="ltr" class=""> -1 from me. It is simple enough for an extension and provides little benefit as a standard library inclusion. </div> <div class="gmail_extra"> <br class=""> <div class="gmail_quote"> On Sun, Dec 20, 2015 at 9:10 PM, Howard Lovatt via swift-evolution <span dir="ltr" class=""><<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>></span> wrote: <br class=""> <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> <div dir="ltr" class=""> +1 to 5.times{stuff} from me. I much prefer library functions to language extensions. <br class=""> <div class=""> <br class=""> </div> <div class=""> -- Howard. <br class=""> </div> </div> <img src="https://u2002410.ct.sendgrid.net/wf/open?upn=3FGfocPbgxkNkmje7djckg9Iw-2BGYY3X6RxJ1tkUXKCqmg65k6m3WyZopTCwWnJqytBBL-2FFrB2iaH7LTey4D9-2BVok8gB6pkwWUbJ34wbQzVNsGkzIshicBInnQHKHf3B-2FPnt82GiqB84e2-2FdaprmfsRb0qQIJtsH1Ns-2BMU2OrbHci-2BF2EKWG1VsCNqVpriZ4iPvX02Z9veattDop4VLn3ExKHlfwgJYS4DLLMU0Wx8h8-3D" alt="" width="1" height="1" border="0" style="min-height:1px!important;width:1px!important;border-width:0!important;margin-top:0!important;margin-bottom:0!important;margin-right:0!important;margin-left:0!important;padding-top:0!important;padding-bottom:0!important;padding-right:0!important;padding-left:0!important" class=""> <br class="">_______________________________________________ <br class=""> swift-evolution mailing list <br class=""> <a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a> <br class=""> <a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a> <br class=""> <br class=""> </blockquote> </div> <br class=""> </div> <img src="https://u2002410.ct.sendgrid.net/wf/open?upn=5xu02FVv-2BCbxTLHpBsC0RVeXVC5uCln3pUIIeLTlIi2FTGkhQSEBQ7H24l1e6tdSKD2-2F8JQAp27YVSgIAnyeBb5ZrP-2BFinlELeoG-2BCfUpUZA9oaPIIJ1AFR9a22uYWVPx2WxiHDSLmAvjQuLxj-2F5Alkhaw4iJU7WSZHn3hDJ0YaiLvF7WURG0HJchJnCbMTvvrmUJaGH0oyNSelStaUlg11iY0rXljWGniakPYOYJfY-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;" class=""> _______________________________________________ <br class="">swift-evolution mailing list <br class=""> <a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a> <br class=""> <a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a> <br class=""> </div> </blockquote> </div> <br class=""> <img src="https://u2002410.ct.sendgrid.net/wf/open?upn=aT-2FLnFEhPSFDSL7Gmx0xJo5o6hMhPoYO5Zn1SY30wfe3jE7sTdjZJPzgjej0TW2BGXz8M-2Fh8XSeACa-2BzvK9U5Uc-2BC75olPFvxzLPVypZaVfJSQfX63f2ejAyG7q8fjRvXHBqm2sqOW4JzbmpKt8qXEFd3FiyY0RqGFKM2QcFlDTWcPaWBzMTAFIDyWdzJ7a1OqAiHOBfoxP2S06QO6-2BqiYgOQ3bb1L4HQNjsR4M8xXA-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;" class=""> </div> _______________________________________________ <br class="">swift-evolution mailing list <br class=""> <a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a> <br class=""><a dir="ltr" href="https://lists.swift.org/mailman/listinfo/swift-evolution" x-apple-data-detectors="true" x-apple-data-detectors-type="link" x-apple-data-detectors-result="16">https://lists.swift.org/mailman/listinfo/swift-evolution</a> <br class=""> </div> </blockquote> </div> <br class=""> </div> <img src="https://u2002410.ct.sendgrid.net/wf/open?upn=bRwbJtRAtyuKyjhktKFujcXtJMJ0BKcAmTwXAUGP5GHhJQNePaeBnxaLtu0PfXSM-2FKwweRotBoNCXBf6sZs0uZbz5wdVLK1kTUjEvBYDfAv1a38EBQv07TPJiKfdceFCMF0SSz4xf-2BWXisKxv98rA1NI1sygXh30MxLBnjR9QHTXW3BIRo0MGUI55sTV8w3HH4sthv6-2FS8EUWBlzZBcaXEvPd0xUJIl16rUX9poNlHs-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;"> <br><br></div>