Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
为什么在 Groovy 中以下是正确的?
0 > null
它是由选择还是仅仅是 compareTo 实现的结果?
我正在使用 Groovy 2.0.5。
在 Groovynull中是最低的元素,所以一切都是> null
null
> null
assert 'tim' > null assert 0 > null assert -1 > null assert Double.NEGATIVE_INFINITY > null
这意味着这样的事情可以工作:
[ 1, null, 3 ].sort()
否则会发生什么?如果你想让它工作,你必须说“null 比任何东西都低”或“null 比任何东西都高” ......
Groovy 选择了前者