diff --git a/src/list.cr b/src/list.cr index b5801b9..e57b9c9 100644 --- a/src/list.cr +++ b/src/list.cr @@ -128,9 +128,12 @@ class DoubleLinkedList(V) i += 1 end - new_node.next = current.next - current.next = new_node - new_node.previous = current + new_node.next = current + new_node.previous = current.previous + + current.previous.not_nil!.next = new_node + current.previous = new_node + @size += 1 new_node end