mirror of
https://github.com/samber/lo.git
synced 2026-04-22 23:47:11 +08:00
23 lines
465 B
Markdown
23 lines
465 B
Markdown
---
|
|
name: Slice
|
|
slug: slice
|
|
sourceRef: it/seq.go#L680
|
|
category: it
|
|
subCategory: sequence
|
|
signatures:
|
|
- "func Slice[T any, I ~func(func(T) bool)](collection I, start, end int) I"
|
|
playUrl: "https://go.dev/play/p/5WqJN9-zv"
|
|
variantHelpers:
|
|
- it#slice#drop
|
|
similarHelpers:
|
|
- core#slice#slice
|
|
- core#slice#chunk
|
|
position: 80
|
|
---
|
|
|
|
Returns a sub-sequence from start index to end index (exclusive).
|
|
|
|
```go
|
|
result := it.Slice(it.Range(1, 10), 2, 5)
|
|
// [3, 4, 5]
|
|
``` |