setItem() function
This commit is contained in:
parent
9307473d08
commit
905b2af7fa
10
list-type.go
10
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
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user