Back to Lo

It Trimlast

docs/data/it-trimlast.md

1.53.0331 B
Original Source

TrimLast removes all the trailing cutset from the collection.

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

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