I’m a bit curious to the dessision to clear the list before assigning it new values. Isn’t this redundant since we are changing the reference to a new list passed into the method anyway?
1 Like
It may just be a memory thing. We are changing references, so the old data remains in memory, but there is just no more reference to it. The garbage collector will pick it up the next time it does its thing, but clearing the list first just frees up that memory sooner. I think.
2 Likes
Strictly speaking, it’s a good practice, it ensures the GC process begins, and it’s a good habit for the vast majority of times when clearing the list realy must be done. I do believe, however, that in this case, it isn’t technically necessary.
2 Likes
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.