这个操作符称为什么?它用于< => [英] what is this operator called and what is it used for <=>

查看:132
本文介绍了这个操作符称为什么?它用于< =>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近在挖掘Groovy时遇到了这个神奇的操作员:< =>



Groovy真的让我对elvis操作员感到满意吗?和?:我现在经常使用并且非常希望使用Java。有了这个新的运营商,我只发现这个参考。它似乎使比较容易得多。我的问题是它如何处理空值,以及它如何比较非Comparable对象。这个操作符有一个名字,我找不到它谷歌搜索。

解决方案

你有这里是一个运营商列表。它被称为Spaceship运算符。它无效处理null 。 p>

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 now and very much wish were in Java. With this new operator, I have only found this reference. It seems to make comparators much easier. My question is how does it handle null values and how does it compare non Comparable object. Does this operator have a name, I couldn't find it Googling.

解决方案

You got a list of operators here. It is called the "Spaceship" operator. It handles null without problem.

这篇关于这个操作符称为什么?它用于&lt; =&gt;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆