Back to Lo

It Trimsuffix

docs/data/it-trimsuffix.md

1.53.0355 B
Original Source

TrimSuffix removes all the trailing suffix from the collection.

go
collection := func(yield func(int) bool) {
    yield(1)
    yield(2)
    yield(3)
    yield(4)
    yield(3)
    yield(4)
}

trimmed := it.TrimSuffix(collection, []int{3, 4})
var result []int
for item := range trimmed {
    result = append(result, item)
}
// result contains [1, 2]