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

Daniel Sun commented on GROOVY-9433:
------------------------------------

Here is the workaround. Remember we can always eliminate ambiguities with 
parentheses.
{{true ? (["abc"] as String[]) : new String[0]}}

> grammar ambiguity with ternary expression being confused with safe indexing
> ---------------------------------------------------------------------------
>
>                 Key: GROOVY-9433
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9433
>             Project: Groovy
>          Issue Type: Task
>    Affects Versions: 3.0.1
>            Reporter: Paul King
>            Priority: Major
>
> The following works fine in 2.5.9 and 3.0.1:
> {code:java}
> false ? ['abc'] : ['def']
> {code}
> but the following onyl works in 2.5.9:
> {code:groovy}
> true ? ["abc"] as String[] : new String[0]
> {code}
> In 3.0.1 it gives:
> {noformat}
> groovy.lang.MissingPropertyException: No such property: abc for class: 
> java.lang.Boolean
> {noformat}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to