Return the index of the added element
This commit is contained in:
6
atom.go
6
atom.go
@@ -16,12 +16,14 @@ type Countable interface {
|
||||
*xml.Attr | *Person | *Category | *Link | *ExtensionElement | *Entry
|
||||
}
|
||||
|
||||
// addToSlice adds a Countable to to a *[]Countable
|
||||
func addToSlice[C Countable](slice *[]C, countable C) {
|
||||
// addToSlice adds a Countable to to a *[]Countable. It returns an int.
|
||||
func addToSlice[C Countable](slice *[]C, countable C) int {
|
||||
if *slice == nil {
|
||||
*slice = make([]C, 0)
|
||||
}
|
||||
*slice = append(*slice, countable)
|
||||
|
||||
return len(*slice) - 1
|
||||
}
|
||||
|
||||
// deleteFromSlice deletes the Countable with the index from the *[]Countable.
|
||||
|
Reference in New Issue
Block a user