3 ms·
Reminds me of a C++ pattern some guy I worked with years ago used to love to simplify complex if checks - using do...while(false) to create a scope you can easi
by dvirsky 6y ago
Reminds me of a C++ pattern some guy I worked with years ago used to love to simplify complex if checks - using do...while(false) to create a scope you can easily break out of. e.g.
bool success = false;
do {
if (!someCondition) break;
if (!otherCondition) break;
...
success = true;
} while(false);
if (!success) {
...
}
I personally disliked it, plus it can lead to funky behavior under optimization.
- deleted 6y ago[deleted]
- Igelau 6y agoWow! This guy must have been told he wasn't allowed to use goto anymore. The do-while block here is just a nameless replacement for the label.