[swift-evolution] else clause for loops like that in Python

Brent Royal-Gordon brent at architechies.com
Tue Dec 8 16:50:32 CST 2015


> But to avoid confusion, maybe rename “else” to “nobreak”:
> 
> for i in 0..<10 {
>  if i == 5 { break }
> } nobreak {
>  // no break occurred
> }

I’ve often wanted an else clause on loops—but one that would run only if the loop went through zero iterations. I can’t imagine when I would ever use `nobreak`.

-- 
Brent Royal-Gordon
Architechies



More information about the swift-evolution mailing list