Comparing null and number in groovy
groovy
Solution
In Groovy `null` is the lowest possible element, so everything is `> null`
assert 'tim' > null
assert 0 > null
assert -1 > null
assert Double.NEGATIVE_INFINITY > null
This means things like this can work:
[ 1, null, 3 ].sort()
Otherwise what would happen? If you want this to work, you have to say "null is lower than anything" or "null is higher than anything"...
Groovy chose the former
Problem
Why is the following true in Groovy? ``` 0 > null ``` Is it by choice or is it just a consequence of the implementation of compareTo? I'm using Groovy 2.0.5.