I’ve always thought that appending a list to another one meant copying the objects from the first list and then pointing to the appended list as described for example here.
However, in this blog post and in its comment, it says that it is only the pointers that are copied and not the underlying objects.
So what is correct?
I’ve always thought that appending a list to another one meant copying the objects
Share
If you mean this statement then the answer is seems to be pretty simple. Author of the first article is talking about list node elements when he says
nodes. Node element is not the same as the list item itself. Take a look at the pictures in the first article. There are arrows going from every element to the next node. These arrows are pointers. But integer type (which is put into the list) has no such pointers. There is probably somelist nodetype which wraps those integers and stores the pointers. When author says thatnodes must be copieshe is talking about these wrappers being copied. The underlying objects (if they were not value types as in this case) would not be cloned, new wrappers will point to the same object as before.