Rename id in Delete methods to index

This commit is contained in:
2024-10-20 12:35:26 +02:00
parent b6b8970810
commit bcf2532372
6 changed files with 58 additions and 58 deletions

View File

@@ -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
}