what is this operator called and what is it used for <=>

后端 未结 4 972
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-18 23:00

I recently came across this magical operator when digging into Groovy: <=>

Groovy has really made me happy with elvis operators ?. and ?: which I use constantly

4条回答
  •  囚心锁ツ
    2021-01-18 23:36

    It's called the spaceship operator and is also commonly used for comparison in Ruby.

    http://www.objectpartners.com/2010/02/08/the-groovy-spaceship-operator-explained/

提交回复
热议问题