public Collection findAll(Closure
closure)
Return a collection that matches to thi closure.
HelloWorld.groovy
numbers = [2, 5, 8, 1, 32, 49, 65, 43, 70, 21, 42] def numberDivisibleBy7 = numbers.findAll { it % 7 == 0} println "Numbers in the list $numbers that are divisible by 7 are : $numberDivisibleBy7"
Output
Numbers in the list [2, 5, 8, 1, 32, 49, 65, 43, 70, 21,
42] that are divisible by 7 are : [49, 70, 21, 42]
No comments:
Post a Comment