What is the name of the <=> operator in Ruby? What do they call it?

Ruby has an operator <=>. In the API, they will not give his name, simply:

The class must define the operator <=> ...

Comparable applications <=> for the implementation of conventional comparison ...

... objects in the collection must also implement the meaningful operator <=> ...

What's his name?

+5
source share
4 answers

See @Tony above. However, he also called (in slang) "the spacecraft operator."

+5
source

He called the Combined Comparison Operator

. 0, , 1, -1, .

(a <=> b) returns -1.
+4

This is called the combined comparison operator. Returns 0 if the first operand is equal to the second, 1 if the first operand is greater than the second and -1 if the first operand is less than the second.

Source

+2
source

Ive also heard it's just called a double hash rocket

+1
source

All Articles