Booleans can also be "negated" using the "not" operator - !
.
booleanhaveOreosInHouse = true; booleanstuckToCalorieLimit = !haveOreos;
So in this case, I have stuck to my calorie limit if there are not Oreos in the house.
haveOreosInHouse | stuckToCalorieLimit |
---|---|
false | true |
true | false |