groovy - reference variable used in ternary conditional? (ex: var?this:null) -


is there way reference first part of ?: statement in groovy?

for example, there way shorten

def time = map.get('time') ? map.get('time').get('milliseconds') : null 

to like

def time = map.get('time') ? it.get('milliseconds') : null 

, "it" references first part of command?

it sounds want use safe navigation operator:

def time = map.get('time')?.get('milliseconds') 

if map.get('time') returns null reference, result of overall expression null, , get('milliseconds') won't called.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -