[
https://issues.apache.org/jira/browse/GROOVY-4018?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15457497#comment-15457497
]
ASF GitHub Bot commented on GROOVY-4018:
----------------------------------------
GitHub user jwagenleitner opened a pull request:
https://github.com/apache/groovy/pull/409
GROOVY-4018: Make the Groovy truth value of NaN be false
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/jwagenleitner/groovy
GROOVY-4018-groovytruth-NaN
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/groovy/pull/409.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #409
----
commit 7b3401e1ff697a230ae232e510e711fc9cc4aaee
Author: John Wagenleitner <[email protected]>
Date: 2016-09-01T23:39:31Z
GROOVY-4018: Make the Groovy truth value of NaN be false
----
> 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.
> {noformat}
> def result = a?.b?.calcX(...)
> if (result) {
> // now I have a valid non-null number
> }
> {noformat}
> 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)
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)