Boolean Operators
THE OPERATORS
[!]
[&&]
[||]
[==]
[!=]
[<]
[>]
[<=]
[>=]
DESCRIPTION
The syntax varies per operator. However, they all return a
boolean
value. The format used below is:
- English Name:
syntax
- Explanation
- not:
!
boolean
- The not operator returns
true
if boolean is
false
and returns false
if boolean
is true
.
- and: boolean_1
&&
boolean_2 - The and operator returns
true
if boolean_1
and boolean_2 are both true
, otherwise it returns
false
.
- or: boolean_1
||
boolean_2
- The or operator returns
true
if either boolean_1
or boolean_2 is true
, otherwise returns
false
- equals: expression_1
==
expression_2
- The equals operator returns
true
if expression_1
and expression_2 are identical, otherwise false
.
For example, if the expressions are integers, you will get
a true
result if they are the same integer. For
objects
, you will get a true result if and only if
expression_1 and expression_2 are the exact same
object
.
- not equals: expression_1
!=
expression_2
- The not equals operator returns
true
if expression_1
and expression_2 are not identical, otherwise false
.
This is the same as ! (
expression_1 !=
expression_2 )
.
- less than: value_1
<
value_2
- The less than operator returns
true
if
the numeric value_1 is less than value_2,
false
otherwise.
- greater than: value_1
>
value_2
- The greater than operator returns
true
if
the numeric value_1 is greater than value_2,
false
otherwise.
- less than or equals: value_1
<=
value_2
- The less than or equals operator returns
true
if
the numeric value_1 is less than or equals value_2,
- greater than or equals: value_1
>=
value_2
- The greater than or equals operator returns
true
if
the numeric value_1 is greater than or equals value_2,
David Maxwell,
who is still writing this, would like to
hear your comments and suggestions.