Logical Operators

You use logical operators to evaluate conditions.

not

Boolean—unary not.

Returns:

  • True—when a condition is false

  • False—when a condition is true

Example:

not true

and

Boolean—binary and. Commutative.

Returns:

  • True—if both conditions are true

  • False—if either condition is false

Example:

true and false

or

Boolean—binary or. Commutative.

Returns:

  • True—if either condition is true

  • False—if both conditions are false

Example:

true or false

==

Condition—is equal to

Example:

2 == 1

!=

Condition—is not equal to

Example:

"Denver" != "Maine"

<

Ordinal condition—less than

Example:

0 < -0.1

>

Ordinal condition—more than

Example:

10 > 0.1

<=

Ordinal condition—less than or equal to

Example:

0 <= 50

>=

Ordinal condition—more than or equal to

Example:

10 >= 0