Hi chathurad,
As nmrao said, 'Groovy' language is simple and groovy, you are able to take the better way to deal with your requirements. Groovy has many extended methods based on Java Class / method.
as for "it", a closure using an implicit parameter. you can also specify a parameter like {param -> xxxxx}
(Example)
for list, often using each / collect / any / every / find / findAll / eachWithIndex...etc
def alist = [100, 200, 300, 400, 500]
alist.each {
println(it) //output: 100, 200, 300, 400, 500
}
alist.each {element ->
println(element) //output: 100, 200, 300, 400, 500
}
def blist = alist.collect {
if (it > 300)
it
}
println(blist.findAll {it != null}) //output: [400, 500]
def clist = alist.find {
it > 300
}
println(clist) //output: 400
def dlist = alist.findAll {
it > 300
}
println(dlist) //output: [400, 500]
def t = alist.every {
it > 99
}
println(t) //output: true
def t2 = alist.any {
it > 400
}
println(t2) //output: true
alist.eachWithIndex {element, index ->
if (element > 300)
println("$index: $element") //output: 3: 400 / 4: 500
}
you would access official website: http://www.groovy-lang.org/single-page-documentation.html to understand more. and check API: http://www.groovy-lang.org/api.html to understand more usage based on language.
Thanks,
/Aaron