Comparison operations are supported by all objects. They all have the
same priority (which is higher than that of the Boolean operations).
Comparisons can be chained arbitrarily, e.g. x < y <= z
is
equivalent to x < y and y <= z
, except that y
is
evaluated only once (but in both cases z
is not evaluated at
all when x < y
is found to be false).
This table summarizes the comparison operations:
Operation | Meaning | Notes |
---|---|---|
< |
strictly less than | |
<= |
less than or equal | |
> |
strictly greater than | |
>= |
greater than or equal | |
== |
equal | |
<> |
not equal | (1) |
!= |
not equal | (1) |
is |
object identity | |
is not |
negated object identity |
, Notes:
<>
and !=
are alternate spellings for the same operator.
(I couldn't choose between ABC and C! :-)
(Implementation note: objects of different types except numbers are ordered by their type names; objects of the same types that don't support proper comparison are ordered by their address.)
Two more operations with the same syntactic priority, in
and
not in
, are supported only by sequence types (below).
guido@CNRI.Reston.Va.US