[
https://issues.apache.org/jira/browse/GROOVY-9522?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17091333#comment-17091333
]
Daniel Sun commented on GROOVY-9522:
------------------------------------
FYI.
http://groovy-lang.org/releasenotes/groovy-3.0.html
{code:java}
String[] array = ['a', 'b']
assert 'b' == array?[1] // get using normal array index
array?[1] = 'c' // set using normal array index
assert 'c' == array?[1]
array = null
assert null == array?[1] // return null for all index values
array?[1] = 'c' // quietly ignore attempt to set value
assert null == array?[1]
def personInfo = [name: 'Daniel.Sun', location: 'Shanghai']
assert 'Daniel.Sun' == personInfo?['name'] // get using normal map index
personInfo?['name'] = 'sunlan' // set using normal map index
assert 'sunlan' == personInfo?['name']
personInfo = null
assert null == personInfo?['name'] // return null for all map
values
personInfo?['name'] = 'sunlan' // quietly ignore attempt to
set value
assert null == personInfo?['name']
{code}
> Throwing NPE when I use ternary operator with something special
> ---------------------------------------------------------------
>
> Key: GROOVY-9522
> URL: https://issues.apache.org/jira/browse/GROOVY-9522
> Project: Groovy
> Issue Type: Bug
> Components: parser
> Affects Versions: 3.0.3
> Environment: Win10/MacOS
> Zulu OpenJDK 11
> Reporter: Huabin Zhang
> Priority: Critical
>
> Hi, I got NPE instead of empty string when I wrote the following snippet:
>
> {code:java}
> static String a() {
> null
> }
> static String b() {
> ''
> }
> def x = a() ? [b(), a()].join(',') : b() // NPE
> //def x = a() ? [b(), a()] : b() // OK
> //def x = a() ? ([b(), a()]).join(',') : b() // OK
> x == ''
> {code}
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)