[swift-evolution] else clause for loops like that in Python
Alex Chan
alex at alexwlchan.net
Tue Dec 8 15:50:38 CST 2015
I’d be inclined not to add this feature.
My impression is that (in Python) many people have either never come across this feature or find its behaviour confusing. I don’t think it’s a particularly widely used feature, and I don’t think it’s necessary for Swift.
If we do add it, I strongly agree with changing the name. One of the biggest confusions in Python is the mismatch between if…else and for…else. Renaming it would help.
— Alex
(For the non-Python programmers on the list: the “else” is an optional branch at the end of for/while loops that runs only if the loop exits cleanly/doesn’t break.)
> On 8 Dec 2015, at 18:35, Amir Michail via swift-evolution <swift-evolution at swift.org> wrote:
>
> But to avoid confusion, maybe rename “else” to “nobreak”:
>
> for i in 0..<10 {
> if i == 5 { break }
> } nobreak {
> // no break occurred
> }
>
>
> _______________________________________________
> 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