Groovy Functions


def numbers = 0..9
println numbers.class
for (num in numbers) {
if (isEven(num)) {
  println num
}
}

def isEven(num) {
num%2 == 0
}
​
​

Output of Script

 81 ms
class groovy.lang.IntRange
0
2
4
6
8

Comments

Popular posts from this blog

Array and Object Creation - JavaScript

Groovy Tuples

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