groovy Spread Operator

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

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() } == []


Got any groovy Question?