<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="">By the way and/or for all of you who like the idea of a .times method:<div class=""><br class=""></div><div class="">I’ve just setup a library for features like this `times` method and implemented the suggested method there. Feel free to contribute code / provide feedback via that third party library (as suggested by Chris) here:</div><div class=""><br class=""></div><div class=""><a href="https://github.com/Flinesoft/HandySwift" class="">https://github.com/Flinesoft/HandySwift</a></div><div class=""><br class=""></div><div class="">– Cihat</div><div class=""><br class=""><div class=""><div><blockquote type="cite" class=""><div class="">Am 18.12.2015 um 23:42 schrieb Cihat Gündüz 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 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="">As far as I can remember it was never a goal of Swift to be a purely object-oriented language. Instead I can find expressiveness stated explicitly amongst the three main goals behind the language here: <a href="https://swift.org/about/#platform-support" class="">https://swift.org/about/#platform-support</a><div class=""><br class=""></div><div class="">Therefore I feel it is okay if the language becomes more expressive in a way that is less object-oriented. I see the suggested method as a functional construct.</div><div class=""><br class=""></div><div class="">– Cihat</div><div class=""><br class=""></div><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">Am 18.12.2015 um 23:22 schrieb Kenny Leung <<a href="mailto:kenny_leung@pobox.com" class="">kenny_leung@pobox.com</a>>:</div><br class="Apple-interchange-newline"><div class=""><div class="">I don’t agree with this on the grounds that it isn’t very object-oriented. That is, it does not conform with what one usually associates with an integer. A number has certain intrinsic properties: 5 is greater than 4 but less than 6. If you’re a synesthete, it may have the color blue. But I never think of there being a big number 5 that takes something and repeats it 5 times. I think of a person taking something and doing it over 5 times.<br class=""><br class="">-Kenny<br class=""><br class=""><blockquote type="cite" class="">On Dec 18, 2015, at 10:25 AM, Cihat Gündüz via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:<br class=""><br class="">Dear Swift-Community,<br class=""><br class="">I’d like to propose an addition of a useful method, especially for beginners that also makes Swift much more readable in some situations: The addition of a .times method to Integer type(s).<br class=""><br class="">For example recently in one of my projects I wanted to test the scalability of an important piece of code and wrote this method:<br class=""><br class=""> func testPerfQualityInPercentWithoutQualityImprovements() {<br class=""> self.measureBlock {<br class=""> let expectedQuality = 33.33<br class=""> 0.stride(to: 5_000, by: 1).forEach { _ in<br class=""> XCTAssertEqualWithAccuracy(self.crossword.qualityInPercent, expectedQuality, accuracy: 0.1) <br class=""> } <br class=""> }<br class=""> }<br class=""><br class="">As you can see what I basically wanted was to repeat the test some thousand times. I also like to use the Ruby language and one thing I love about it is that it has some really handy methods integrated to the language in situations like this which make the code very readable and therefore fun to use.<br class=""><br class="">I’m an even bigger fan of Swift so I’d love to see such useful methods appear in Swift, too and this is the first I came across that I really missed. So I’m asking myself, what if I could write the same code above like this:<br class=""><br class=""> func testPerfQualityInPercentWithoutQualityImprovements() {<br class=""> self.measureBlock {<br class=""> let expectedQuality = 33.33<br class=""> 5_000.times {<br class=""> XCTAssertEqualWithAccuracy(self.crossword.qualityInPercent, expectedQuality, accuracy: 0.1) <br class=""> } <br class=""> }<br class=""> }<br class=""><br class="">I think it could be added to the Swift standard library very easily (for example by using the .stride method like I used) without any side effects and has enough advantages to be part of Swift itself. What do you think?<br class=""><br class="">I wish you all the best,<br class="">Cihat<br class=""><br class=""><br class="">P.S.: This is my very first mail in such a mailing list so I did everything correctly. ^.^<br class=""><br 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=""></blockquote><br class=""></div></div></blockquote></div><br class=""></div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=aT-2FLnFEhPSFDSL7Gmx0xJo5o6hMhPoYO5Zn1SY30wfcNC2vl01U0aO21ZzB0A6xuYI7rMMlEB-2BY-2F9e9ErYMhUuh8FAHbNJBM7boxv83Cway8GD89REnbDxRWffRTsh-2BUjwulZtaXblX-2B7M1lk34fFSquoI-2BXnk8DfxRRPLsebriUC154eqoG5c6aumzQdwu8kmX7HtwaCEWrkEaHbWLSbV90wzr4ZAD44GRVUcTQidY-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="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></div></div></body></html>