Code:
class GroovyController {
def index(){
println '-----------------------------------'
def array = [10,20,30,40,50]
array.eachWithIndex {it, i->
println 'array['+i+'] = '+it
}
render ''
}
}
Output:
array[0] = 10
array[1] = 20
array[2] = 30
array[3] = 40
array[4] = 50
class GroovyController {
def index(){
println '-----------------------------------'
def array = [10,20,30,40,50]
array.eachWithIndex {it, i->
println 'array['+i+'] = '+it
}
render ''
}
}
Output:
array[0] = 10
array[1] = 20
array[2] = 30
array[3] = 40
array[4] = 50
No comments:
Post a Comment