You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Huabin Zhang (Jira)" <ji...@apache.org> on 2020/04/24 07:57:00 UTC

[jira] [Comment Edited] (GROOVY-9522) Throwing NPE when I use ternary operator with something special

    [ https://issues.apache.org/jira/browse/GROOVY-9522?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17091301#comment-17091301 ] 

Huabin Zhang edited comment on GROOVY-9522 at 4/24/20, 7:56 AM:
----------------------------------------------------------------

Oh~~,
{code:java}
?[...]{code}
is a new feature.

 

For your suggestion, +1, it's easier to distinguish Safe Indexing and Ternary Operator.


was (Author: digitarts):
Oh~~,
{code:java}
?[...]{code}
is a new feature.

 

For Paul's suggestion, +1, it's easier to distinguish Safe Indexing and Ternary Operator.

> 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)