You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Scott.Wu (Jira)" <ji...@apache.org> on 2020/09/07 15:19:00 UTC
[jira] [Created] (GROOVY-9725) Elvis operator covert double to null
in addiction
Scott.Wu created GROOVY-9725:
--------------------------------
Summary: Elvis operator covert double to null in addiction
Key: GROOVY-9725
URL: https://issues.apache.org/jira/browse/GROOVY-9725
Project: Groovy
Issue Type: Bug
Components: GroovyScriptEngine
Affects Versions: 2.5.13, 2.4.19
Reporter: Scott.Wu
Below statement will return error unexpected:
{code:java}
// code placeholder
def vo = [INIT:0.00, PURCHASED:null]
println (vo.INIT?:0.00) + (vo.PURCHASED?:0.00)
{code}
The error :
Caught: java.lang.NullPointerException: Cannot execute null+0.00
java.lang.NullPointerException: Cannot execute null+0.00
at jdoodle.run(jdoodle.groovy:2)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
Note: Below expressions report errors as well:
{code:java}
// code placeholder
println (vo.INIT?:0.00 + vo.PURCHASED?:0.00)
println (vo.INIT?:0.00) + (vo.PURCHASED?:0.00)
println vo.INIT?:0.00 + vo.PURCHASED?:0.00
{code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)