mirror of
https://github.com/rjNemo/underscore
synced 2026-06-06 02:26:42 +00:00
* last function * drop function * add documentation * fix CI Co-authored-by: Ruidy <rnemausat@newstore.com>
12 lines
303 B
Go
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
|
|
}
|