underscore/drop.go
Ruidy c00d9af59f
drop (#18)
* last function

* drop function

* add documentation

* fix CI

Co-authored-by: Ruidy <rnemausat@newstore.com>
2022-03-21 18:04:38 +01:00

12 lines
303 B
Go

package underscore
// Drop returns the rest of the elements in a slice.
// Pass an index to return the values of the slice from that index onward.
func Drop[T any](values []T, index int) (rest []T) {
for i, value := range values {
if i != index {
rest = append(rest, value)
}
}
return rest
}