You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Steve Tekell (JIRA)" <ji...@apache.org> on 2016/08/30 22:00:22 UTC
[jira] [Updated] (GROOVY-4018) Make the Groovy truth value of NaN
be false
[ https://issues.apache.org/jira/browse/GROOVY-4018?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Steve Tekell updated GROOVY-4018:
---------------------------------
Description:
Similar to null and empty-string, have Groovy evaluate NaN as false rather than true.
def x = a?.b?.calcX(...)
if (x) {
// 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 follow should work
assert !(Double.NaN)
assert !((Double.NaN as Boolean) == true)
assert ((Double.NaN as Boolean) == false)
was:
Similar to null and empty-string, have Groovy evaluate NaN as false rather than true.
def x = a?.b?.calcX(...)
if (x) {
// 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
> Make the Groovy truth value of NaN be false
> -------------------------------------------
>
> Key: GROOVY-4018
> URL: https://issues.apache.org/jira/browse/GROOVY-4018
> Project: Groovy
> Issue Type: Improvement
> Components: groovy-runtime
> Reporter: Steve Tekell
>
> Similar to null and empty-string, have Groovy evaluate NaN as false rather than true.
> def x = a?.b?.calcX(...)
> if (x) {
> // 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 follow should work
> assert !(Double.NaN)
> assert !((Double.NaN as Boolean) == true)
> assert ((Double.NaN as Boolean) == false)
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)