Closed geektortoise closed 3 years ago
@geektortoise What do you mean by "odd behavior"? :)
Do you mean that modifying the object in list.get(i)
modify the object in collection.get(i)
too (because same object)?
In this case, If I have collection = [model1, model2] after this loop, I got in list the value [model2, model2] More exactly, the flow is list = [] list = [model1] list = [model2,model2]
I would expect a [model1,model2] result
If a put some models in a Map or a List, there is odd behavior
I guess it is a reference problem due to the fact that get(index) use this.modelInstance
Solution : clone it before return a model ?