Groovy Operator Overloading - Spread Operator

//Spread operator:  invoke an action on all items of an aggregate object.

def technologies ['Groovy','Grails','Gradle']
t1=technologies*.toUpperCase()
t2 technologies.collect it?.toUpperCase(}
println t1
println t2

//t1 equivalent to t2


Output of Script

 20 ms

[GROOVY, GRAILS, GRADLE]
[GROOVY, GRAILS, GRADLE]

Comments

Popular posts from this blog

தீபம் பிளக்ஸ்

காது புடி வாத்தியார்

PCF - Cloud Foundry Overview - Starting, Restarting and Restaging applications