Boolean Implication

Boolean implication A implies B simply means “if A is true, then B must be true”. This implies (pun intended) that if A isn’t true, then B can be anything. Thus: False implies False -> True False implies True -> True True implies False -> False True implies True -> True This can also be … Read more

Should I always use the AndAlso and OrElse operators?

From MSDN: Short-Circuiting Trade-Offs Short-circuiting can improve performance by not evaluating an expression that cannot alter the result of the logical operation. However, if that expression performs additional actions, short-circuiting skips those actions. For example, if the expression includes a call to a Function procedure, that procedure is not called if the expression is short-circuited, … Read more

How do I test if a variable does not equal either of two values?

Think of ! (negation operator) as “not”, || (boolean-or operator) as “or” and && (boolean-and operator) as “and”. See Operators and Operator Precedence. Thus: if(!(a || b)) { // means neither a nor b } However, using De Morgan’s Law, it could be written as: if(!a && !b) { // is not a and is … Read more

False or None vs. None or False

The expression x or y evaluates to x if x is true, or y if x is false. Note that “true” and “false” in the above sentence are talking about “truthiness”, not the fixed values True and False. Something that is “true” makes an if statement succeed; something that’s “false” makes it fail. “false” values … Read more