From f48483b258e116742c99a6f5260690b7d52ef7a6 Mon Sep 17 00:00:00 2001 From: qlw319 <1529899901@qq.com> Date: Fri, 12 Apr 2024 14:51:41 +0800 Subject: [PATCH] fix: list.first is nil not check --- lists/singlylinkedlist/singlylinkedlist.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lists/singlylinkedlist/singlylinkedlist.go b/lists/singlylinkedlist/singlylinkedlist.go index a4126021..ef65edbf 100644 --- a/lists/singlylinkedlist/singlylinkedlist.go +++ b/lists/singlylinkedlist/singlylinkedlist.go @@ -78,8 +78,7 @@ func (list *List[T]) Prepend(values ...T) { // Get returns the element at index. // Second return parameter is true if index is within bounds of the array and array is not empty, otherwise false. func (list *List[T]) Get(index int) (T, bool) { - - if !list.withinRange(index) { + if !list.withinRange(index) || list.first == nil { var t T return t, false }