Back to Lo

It Dropwhile

docs/data/it-dropwhile.md

1.53.0400 B
Original Source

DropWhile drops elements from the beginning of a sequence while the predicate returns true.

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

filtered := it.DropWhile(collection, func(x int) bool {
    return x < 3
})
var result []int
for item := range filtered {
    result = append(result, item)
}
// result contains [3, 4, 5]