[swift-evolution] repeat loop enhancement

Thorsten Seitz tseitz42 at icloud.com
Wed Dec 16 16:06:41 CST 2015


So, maybe it would be better to make "break" and "continue" behave like "break" and "next" in Ruby and enable non local return?
Then we would not need new syntax for new control structures but could create them as needed within the language.

-Thorsten

Am 14.12.2015 um 12:26 schrieb Brent Royal-Gordon via swift-evolution <swift-evolution at swift.org>:

>> Why not define a times() or timesRepeat() method on Int taking a closure to execute multiple times, like Erica recently posted and which is common in other languages like Ruby, Smalltalk or (I think) Scala:
> 
> In the teaching context, the answer is because it doesn’t actually teach you anything that can be extended to other parts of the language. `times` is a great fit for Ruby because many other Ruby looping constructs are also methods on an object (particularly the `each` loop), and because it works with all the usual loop flow control like `break`. None of these things are true about Swift, so you’re effectively teaching your students a dead end.
> 
> -- 
> Brent Royal-Gordon
> Architechies
> 
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution


More information about the swift-evolution mailing list