hi~
I have a question.
Why does this code in the article missing the sentence “tail = newNode
”
Copynodes()
has, but copyNodes(returningCopyOf:)
has not
private mutating func copyNodes(returningCopyOf node: Node<Value>?) -> Node<Value>? { guard !isKnownUniquelyReferenced(&head) else { return nil } guard var oldNode = head else { return nil } head = Node(value: oldNode.value) var newNode = head var nodeCopy: Node<Value>? while let nextOldNode = oldNode.next { if oldNode === node { nodeCopy = newNode } newNode!.next = Node(value: nextOldNode.value) newNode = newNode!.next oldNode = nextOldNode } return nodeCopy }