Flip a Condition Clearly with NOT
Scenario
An event waitlist gate checks whether a guest can enter. One version stores a clear flag isFull and checks NOT isFull. A confusing draft stores isNotFull and checks NOT isNotFull, causing organizers to misread who gets blocked.
Try it yourself
When the room is full (isFull = true), what does NOT isFull evaluate to? And what if someone mistakenly writes NOT isNotOpen when the door is open (isNotOpen = false)?
| Case | Result |
|---|---|
| isFull = true evaluated with NOT isFull vs direct isFull | Select a choice above to see what happens. |
| isFull = false evaluated with NOT isFull | Select a choice above to see what happens. |
| door is open (isNotOpen = false) checked with confusing NOT isNotOpen vs clear isOpen (true) and NOT isClosed (true when isClosed = false vs invalid non-boolean input 'yes') | Select a choice above to see what happens. |
Reveal the explanation
- isFull = true evaluated with NOT isFull vs direct isFull
NOT isFull -> false (cannot enter); isFull -> true
- isFull = false evaluated with NOT isFull
NOT isFull -> true (can enter immediately without waitlist!)
- door is open (isNotOpen = false) checked with confusing NOT isNotOpen vs clear isOpen (true) and NOT isClosed (true when isClosed = false vs invalid non-boolean input 'yes')
NOT isNotOpen -> true (confusing); clear NOT isClosed -> true; non-boolean string 'yes' must be rejected as invalid
Name boolean flags after the positive or direct state (isFull, isBlocked, isOpen) rather than negated names (isNotOpen). Then NOT simply means 'only when this is false', with zero mental gymnastics.
Download shared test cases
Your turn
Rewrite this confusing rule without a double negative: 'Allow lab equipment loan if NOT isNotReturnedPreviousLoan.' Give both the renamed flag and the clear NOT expression.
Common mistake Keeping 'isNotReturned' and dropping NOT, or flipping both the name and keeping NOT in the same direction.
Check your work
Rename the flag to hasUnreturnedLoan (or previousLoanReturned) and write 'NOT hasUnreturnedLoan' (or 'previousLoanReturned == true').
Quick check
This browser could not save your progress. Changes last until you leave the page.