You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "rkrisztian (Jira)" <ji...@apache.org> on 2020/12/03 09:25:00 UTC
[jira] [Resolved] (GROOVY-9845) Safe star dot operator
[ https://issues.apache.org/jira/browse/GROOVY-9845?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
rkrisztian resolved GROOVY-9845.
--------------------------------
Resolution: Invalid
[~vmj], I've checked your example, it works in my production code.
> Safe star dot operator
> ----------------------
>
> Key: GROOVY-9845
> URL: https://issues.apache.org/jira/browse/GROOVY-9845
> Project: Groovy
> Issue Type: New Feature
> Components: syntax
> Reporter: rkrisztian
> Priority: Major
>
> Currently I would have to write code like this (in the Groovy Console) to be safe:
> {code:groovy}
> def json = [
> messages: [
> [message: 'test']
> ],
> errors: null
> ]
> [
> *(json.messages ? json.messages*.message : []),
> *(json.errors ? json.errors*.message : [])
> ].join('\n')
> {code}
> I would like to request for an operator like {{?\*.}} so I can write something like this:
> {code:groovy}
> [
> *(json.messages?*.message ?: []),
> *(json.errors?*.message ?: [])
> ].join('\n')
> {code}
> Not sure if it can be simplified further, but that's the idea.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)