
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
The Comparison Operators
|
129
"a" <= "z" // true; lowercase "a" comes before lowercase "z"
"A" <= "a" // true; although not equal, "A" comes before "a"
"Z" <= "a" // true; uppercase letters come before lowercase
"hello" <= "hi" // true; "e" comes before "i"
Note that the <= operator is written with the equals sign after the less-than sign. The
following is not a valid operator:
=<.
The Greater-Than-or-Equal-to Operator
The greater-than-or-equal-to operator takes the general form:
operand1 >= operand2
If the operands are numeric, the greater-than-or-equal-to operator returns the Bool-
ean
true if operand1 is mathematically larger than or equal to operand2:
5 >= 6 // false
5 >= 5 // true; note the difference from 5 > 5
–3 >= –6 // true
–6 >= –3 // false
If the operands are strings, this operator returns true if operand1 comes after
operand2 in the Unicode character set or if the operands are identical (according to
the rules described in Chapter 4, “Comparing Strings”); otherwise,
>= returns false:
"a" >= "z" // false; lowercase "a" comes before lowercase "z"
"A" >= "a" // false; "A" comes before "a" and they are not equal
"Z" >= "a" // false; uppercase letters come before lowercase
"hello" >= "hi" // false: "e" comes before "i"
Note that the >= operator is written with the equals sign after the ...