Curriculum

Curriculum

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.

Selected choicePick a choice below
Result—

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)?

Reveal the explanation
  1. isFull = true evaluated with NOT isFull vs direct isFull

    NOT isFull -> false (cannot enter); isFull -> true

  2. isFull = false evaluated with NOT isFull

    NOT isFull -> true (can enter immediately without waitlist!)

  3. 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

An attendance checker blocks checkout if a student's card is flagged. Given isSuspended = false, what is the value of NOT isSuspended?
Show the answer and reasoning

Correct answer true

Since isSuspended is false, NOT false evaluates to true, meaning the student is allowed.