3 ms·
Yeah. I always see the De Morgan's Law being used to make the code look prettier or look less complicated. I'd say it's objectively prettier most of the time,
by revvx 7y ago
Yeah. I always see the De Morgan's Law being used to make the code look prettier or look less complicated.
I'd say it's objectively prettier most of the time, but unfortunately that's exactly what introduces double negatives or other ambiguous stuff and makes the code more confusing.
It's a nice refactoring step, though: apply it, extract the condition into a well-named variable and test that condition.