3 ms·
Surprising. I didn't know this construct and I would naturally assume that the else part would execute if the loop never spun (because the list/etc was empty)
by bzb3 6y ago
Surprising. I didn't know this construct and I would naturally assume that the else part would execute if the loop never spun (because the list/etc was empty)
- neverartful 6y agoThis was my guess too.
- amitutk 6y agoYes, the else keyword is not intuitive. The best way to remember for/else is for/nobreak
- neverartful 6y agoRight! nobreak would make it much clearer.
- Dagger2 6y agoIt would involve adding a new keyword to the language though. I imagine there was some desire to avoid that.