3 ms·
I actually quite like that, although usually when I have a large conditional like that I just give it named boolean variables to make it read more like a senten
by overgard 13y ago
I actually quite like that, although usually when I have a large conditional like that I just give it named boolean variables to make it read more like a sentence, IE:
bool exists = b != nil;
bool sameType = b->qid.type == a->qid.type;
bool samePath = b->qid.path == a->qid.path;
...
if(exists && sameType && samePath) {
}
It's also a lot easier to inspect in a debugger, as all the conditions appear in the locals list.
- iso8859-1 13y agoYou could also group related conditions, so that nested if's don't bloat the locals so much: speedIsSlow = dict(downstreamSlow = downstreamSpeed < 200, upstreamSlow = upstreamSpeed < 100) if any(speedIsSlow.values()): connectionIsDead = getPingTime() > 100 if connectionIsDead: print("It's dead, Jim")