Files
lo/docs/data/it-droplastwhile.md
T
2025-10-06 17:16:33 +02:00

702 B

name, slug, sourceRef, category, subCategory, signatures, variantHelpers, similarHelpers, position
name slug sourceRef category subCategory signatures variantHelpers similarHelpers position
DropLastWhile droplastwhile it/seq.go#L180 it sequence
func DropLastWhile[T any, I ~func(func(T) bool)](collection I, predicate func(item T) bool) I
core#slice#droplastwhile
163

DropLastWhile drops elements from the end of a sequence while the predicate returns true.

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

filtered := it.DropLastWhile(collection, func(x int) bool {
    return x > 3
})
var result []int
for item := range filtered {
    result = append(result, item)
}
// result contains [1, 2, 3]