Rename id in Delete methods to index
This commit is contained in:
8
atom.go
8
atom.go
@@ -26,13 +26,13 @@ func addToSlice[C Countable](slice *[]C, countable C) {
|
||||
|
||||
// deleteFromSlice deletes the Countable with the index from the *[]Countable.
|
||||
// It return an error.
|
||||
func deleteFromSlice[C Countable](slice *[]C, id int) error {
|
||||
func deleteFromSlice[C Countable](slice *[]C, index int) error {
|
||||
length := len(*slice)
|
||||
if id > length {
|
||||
return fmt.Errorf("id %v out of range %v", id, length)
|
||||
if index > length {
|
||||
return fmt.Errorf("id %v out of range %v", index, length)
|
||||
}
|
||||
|
||||
*slice = append((*slice)[:id], (*slice)[id+1:]...)
|
||||
*slice = append((*slice)[:index], (*slice)[index+1:]...)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user