setItem() function

This commit is contained in:
Celestino Amoroso 2024-06-04 11:04:00 +02:00
parent 9307473d08
commit 905b2af7fa

View File

@ -147,3 +147,13 @@ func deepSame(a, b any, deepCmp deepFuncTemplate) (eq bool, err error) {
return 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
}