3 ms·
Someone mentioned this instead: while (true) { const bool flag = do_something(); if (!flag) break; } Is it not what grandparent wanted?
by p1esk 11y ago
Someone mentioned this instead:
while (true) {
const bool flag = do_something();
if (!flag) break;
}
Is it not what grandparent wanted?
- mikeash 11y agoYes, that would do it. It would just be nice to have it be better supported in the language rather than working around it like this. Any time you introduce break or continue into a loop you're making it more difficult to follow what's going on, since suddenly the exit condition can be anywhere. Not a big deal, especially if there's only one and it's right at the end, but mildly annoying that it can't be expressed more naturally.