My situation is that I have a class Foo:
class Foo {
List<Bar> barList;
//other stuff
}
and then I want to do:
void process (Foo obj){
obj.getBarList().each {
Bar bar ->
bar = doSomeStuff(bar)
}
}
Will this update the barList attribute in object foo? Or will I have to do something like:
void process (Foo obj){
obj.getBarList().eachWithIndex {
Bar bar ->
bar = doSomeStuff(bar)
obj.getBarList().set(bar, index)
}
}