Groovy Closure

​(1..10).findAll({ it%2==0 }).each({ println "In a closure: $it" })​

Output of Script

 112 ms
In a closure: 2
In a closure: 4
In a closure: 6
In a closure: 8
In a closure: 10
 [2, 4, 6, 8, 10] java.util.ArrayList

Comments

Popular posts from this blog

Array and Object Creation - JavaScript

Groovy Tuples

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