# An error in LinkedList implementation in Chapter 6

**URL:** <https://forums.kodeco.com/t/an-error-in-linkedlist-implementation-in-chapter-6/198926>\
**Category:** Data Structures & Algorithms in Swift\
**Created:** [November 6, 2023, 5:27pm UTC](https://forums.kodeco.com/t/an-error-in-linkedlist-implementation-in-chapter-6/198926 "2023-11-06T17:27:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![exchessplayerh](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/exchessplayerh/32/110937_2.png) [@exchessplayerh](https://forums.kodeco.com/u/exchessplayerh)\
**Post date:** [November 6, 2023, 5:27pm UTC](https://forums.kodeco.com/t/an-error-in-linkedlist-implementation-in-chapter-6/198926/1 "2023-11-06T17:27:37Z")

</div>

1. The function `copyNodes(returningCopyOf node: Node<Value>?)` should return the node itself, not `nil` when copy is not performed. Otherwise, the node is not removed from the list.
2. The insertion function, should use `copyNodes(returningCopyOf node: Node<Value>?)` instead of regular `copyNodes()` for the same reason, `remove` does.
3. This is trickier to correct, and I believe requires different approach to COW - when performing operations on the first node - we create additional reference to `head`, which forces copy to be performed, even when data structure itself is not really copied.

A correction in the source code would be greatly appreciated.
