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

Paul King commented on GROOVY-4875:
-----------------------------------

Groovy already partially does safe index operations, e.g.:
{code}
def list = ['x']
assert list[1] == null
{code}
What would be really useful is checking whether the collection.array was null, 
e.g.:
{code}
def list = null
assert list?[0] == null // NYI but would be equiv to: assert list?.getAt(0) == 
null
{code}

> 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