collections - Remove item from groovy list -
i trying remove item groovy list. i've tried following:
list<user> availableusers = [] availableusers = workers (int = 0; < availableusers.size(); i++) { if (availableusers[i].equals(user)){ availableusers.drop(i) break } }
i've tried:
availableusers.remove(user)
in both cases list gets emptied. have idea what's going on?
fildor right, if want ot remove first occurence of user
in list (minus remove occurrences), need like:
list = list.indexof( user ).with { idx -> if( idx > -1 ) { new arraylist( list ).with { -> a.remove( idx ) } } else list }