groovySpread Operator


Remarks

In most cases, the spread operator *. is identical to calling .collect { it.________ }.

def animals = ['cat', 'dog', 'fish']
assert animals*.length() == animals.collect { it.length() }

But if the subject is null, they behave a differently:

def animals = null
assert animals*.length() == null
assert animals.collect { it.length() } == []