8 ms·
For(;;) allows you to put the looping variable initialization, exit condition, and increment statement in the same line, so you easily get a clear idea of those
by flavio81 9y ago
For(;;) allows you to put the looping variable initialization, exit condition, and increment statement in the same line, so you easily get a clear idea of those three.
- deleted 9y ago[deleted]
- gumby 9y agoI don't know why this got downvoted; true, I was referring to the infinite loop case, but this is a legit (if not C++-specific) case of a benefit of for over while. Likewise do...while is in retrospect, a mistake, because it documents the control strategy in a bad place from a humans-understanding-code point of view.
- flavio81 9y ago>I don't know why this got downvoted; true, I was referring to the infinite loop case, but this is a legit (if not C++-specific) case of a benefit of for over while. Thanks gumby. I simply didn't catch that they were referring only to infinite loops. I though they were debating the usefulness of while versus for, in general.