2 ms·
> Are there scenarios when either operator (cmp or <=>) works, but they have different behaviour? It being Perl, you can basically throw anything at either ope
by darrenf 5y ago
> Are there scenarios when either operator (cmp or <=>) works, but they have different behaviour?
It being Perl, you can basically throw anything at either operator if you like. It's trivial to find examples where the answers are different:
perl -wlE 'say "a" <=> "b"; say "a" cmp "b";'
Argument "b" isn't numeric in numeric comparison (<=>) at -e line 1.
Argument "a" isn't numeric in numeric comparison (<=>) at -e line 1.
0
-1