With Crystal, I can compare two numbers using the <==>
operator. Example:
p! 1 <=> 1
Running this prints:
1 <=> 1 # => 0
The zero signifies that both numbers are equal. If the value is higher, it would return a positive number. If the value is lower, it returns a negative number. I'd like to know if such an operator exists with Python. Trying to use the <==>
operator gives a syntax error:
>>> 1 <==> 1
File "<stdin>", line 1
1 <==> 1
^
SyntaxError: invalid syntax
I can obviously use something like this:
if 1 == 1:
#equal
elif 1 < 1:
#less than
else:
#greater than
But I think it would be simpler to use a universal operator for comparing.