v8.run/go/exp@v0.0.26-0.20230226010534-afcdbd3f782d/util/slice/drop.go (about) 1 package slice 2 3 func Drop[T any](array []T, n int) []T { 4 if len(array) <= n { 5 n = len(array) 6 } 7 return array[n:] 8 } 9 10 func DropRight[T any](array []T, n int) []T { 11 if len(array) <= n { 12 n = len(array) 13 } 14 return array[:len(array)-n] 15 }