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

Uri Moszkowicz commented on GROOVY-4875:
----------------------------------------

The software versions used when reported are probably pretty old so perhaps it 
was an issue then but not now. I just tried it and indeed no index check is 
needed. However, we had bounds checks for good reason, they catch bugs. We 
removed them because sometimes we don't want false positives. Adding an 
explicit safe index operator allows for the best of both worlds. Changing the 
default behavior of the index operator would be quite disruptive to the 
established world of Groovy code though, maybe not worth it at this point.

> Add a safe index operator
> -------------------------
>
>                 Key: GROOVY-4875
>                 URL: https://issues.apache.org/jira/browse/GROOVY-4875
>             Project: Groovy
>          Issue Type: Improvement
>          Components: syntax
>            Reporter: Uri Moszkowicz
>            Priority: Minor
>
> It would be nice if there were a safe navigation operator for subscripts.
> Safe navigation operator:
> a?.b
> Safe index operator:
> a.size() > 0 ? a[0] : null => a?[0]



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to