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

Array and Object Creation - JavaScript

Groovy Tuples

அவன் ஏன் கூலியானான்?