September 2017
Beginner
402 pages
9h 52m
English
The cmp is a universal comparison operator. Its versatility allows comparing both numeric and string data. Consider the following code snippet:
say 10 cmp 2; # 2 is less than 10say "10" cmp "2"; # but "2" is more than "10"
The return value of one of the three possible values of the Order enumeration is Less, Same, or More. The preceding program prints the following output:
MoreLess
If the operands are of different types, they are converted to the same type, as follows:
say 5 cmp "5"; # Same
When you compare pairs with cmp, they are compared in such a way that keys are compared first, and values are compared second. Examine the following examples, where we create three pairs with different keys and values and ...
Read now
Unlock full access