+12

What is the function of this comparison operator '<=>' in ruby?

10 <=>20

10/6/2019 9:09:20 PM

Debbie

1 Answer

New Answer

+1

It's called the spaceship operator. a <=> b := if a < b then return -1 if a == b then return 0 if a > b then return 1 if a and b are not comparable then return nil https://stackoverflow.com/questions/827649/#827656