Saturday, 5 March 2016

How to remove particular index of an element in array of Groovy

Code:

class GroovyController {

def index(){
println '-----------------------------------'
def array = [1,2,3,4,5]
println 'remove 2nd element : '+array.remove(1)
println 'result array : '+array
render ''
}

}

Output:

remove 2nd element : 2
result array : [1, 3, 4, 5]

No comments:

Post a Comment