Groovy code golfing

Other topics

Spread dot operator(*.)

Spread dot operator can be used instead of collect method

(1..10)*.multiply(2) // equivalent to (1..10).collect{ it *2 }
d = ["hello", "world"]
d*.size() // d.collect{ it.size() }

Parallel processing using Gpars

Gpars offers intuitive ways to handle tasks concurrently

import groovyx.gpars.*
GParsPool.withPool { def result = dataList.collectParallel { processItem(it) } }

Contributors

Topic Id: 10651

Example Ids: 31967,31968

This site is not affiliated with any of the contributors.