From d7dd876a5f2b9a4d48d40fbb69b4da1cb10ba6c4 Mon Sep 17 00:00:00 2001 From: Mostafa Negim Date: Fri, 3 Nov 2023 13:41:07 +0330 Subject: [PATCH] Update linked_list.go Fix: add the condition when the list is empy --- Chapter03/linked_list.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Chapter03/linked_list.go b/Chapter03/linked_list.go index 4ba54e3..8930861 100644 --- a/Chapter03/linked_list.go +++ b/Chapter03/linked_list.go @@ -87,6 +87,9 @@ func (linkedList *LinkedList) AddToEnd(property int) { if lastNode != nil { lastNode.nextNode = node + } else { + // List is empty + linkedList.headNode = node } }