Back to Lo

It Countby

docs/data/it-countby.md

1.53.0177 B
Original Source

Counts the number of elements in the collection that satisfy the predicate.

go
result := it.CountBy(it.Range(1, 11), func(item int) bool {
    return item%2 == 0
})
// 5