From 905b2af7fa9f975e383f6d226640076f7b2c2ebc Mon Sep 17 00:00:00 2001 From: Celestino Amoroso Date: Tue, 4 Jun 2024 11:04:00 +0200 Subject: [PATCH] setItem() function --- list-type.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/list-type.go b/list-type.go index f97990e..5b9eba7 100644 --- a/list-type.go +++ b/list-type.go @@ -147,3 +147,13 @@ func deepSame(a, b any, deepCmp deepFuncTemplate) (eq bool, err error) { return } + +func (list *ListType) setItem(index int64, value any) (err error) { + if index >= 0 && index < int64(len(*list)) { + (*list)[index] = value + } else { + err = fmt.Errorf("index %d out of bounds (0, %d)", index, len(*list)-1) + } + return +} +