On page 16, it is mentioned that the Complete() method “doesn’t modify the list”, but by making a shallow copy of ls := *l
and modifying the attributes of elements in ls
you are surely doing the same to *l? If ls is modified, *l should be as well. You aren’t adding or removing any elements, but you are modifying their attributes, so is the quote really correct?
1 Like
Hi @analogue9 . Thank you for your comment. What I meant was the Complete()
method doesn’ t modify the List
itself. It does not add or remove an item to/from the list, therefore the pointer receiver for the list would not be necessary. We still modify the attribute of one of the elements in the list.
But surely to modify the attributes of an element the list, for them to be saved in the list the receiver should be a pointer? Otherwise you would just be modifying an ephemeral copy of the list, or the attributes therein.