In Ruby there is the <=>
operator. In the API they do not name its name, just:
The class must define the <=> operator...
Comparable uses <=> to implement the conventional comparison...
...the objects in the collection must also implement a meaningful <=> operator...
What is its name?
See @Tony's above. However, it's also called (in slang) the "spaceship operator".
It's called the Combined Comparison Operator
Combined comparison operator. Returns 0 if first operand equals second, 1 if first operand is greater than the second and -1 if first operand is less than the second.
(a <=> b) returns -1.
This is called the combined comparison operator. Returns 0 if first operand equals second, 1 if first operand is greater than the second and -1 if first operand is less than the second.
Source
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With