What is the Ruby <=> (spaceship) operator?

后端 未结 6 1865
夕颜
夕颜 2020-11-22 14:42

What is the Ruby <=> (spaceship) operator? Is the operator implemented by any other languages?

6条回答
  •  无人共我
    2020-11-22 15:36

    It's a general comparison operator. It returns either a -1, 0, or +1 depending on whether its receiver is less than, equal to, or greater than its argument.

提交回复
热议问题