Details
-
Improvement
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
Description
Similar to null and empty-string, have Groovy evaluate NaN as false rather than true.
def result = a?.b?.calcX(...) if (result) { // now I have a valid non-null number }
This is how JavaScript treats NaN and like other Groovy design choices, it just makes sense.
Discussed in this thread
http://old.nabble.com/Shouldn't-the-Groovy-truth-value-of-NaN-be-false--tt27348256.html
That is, if NaN was false the following should work:
assert !(Double.NaN)
assert !((Double.NaN as Boolean) == true)
assert ((Double.NaN as Boolean) == false)
Attachments
Issue Links
- is related to
-
GROOVY-3309 comparisons with NaN should always return false
- Open
- relates to
-
GROOVY-4906 Double.NaN == Double.Nan should evaluate to false
- Closed
- links to