Files
lo/docs/data/core-countby.md
T
2025-10-06 17:15:49 +02:00

544 B

name, slug, sourceRef, category, subCategory, playUrl, variantHelpers, similarHelpers, position, signatures
name slug sourceRef category subCategory playUrl variantHelpers similarHelpers position signatures
CountBy countby slice.go#L596 core slice https://go.dev/play/p/ByQbNYQQi4X
core#slice#countby
core#slice#count
core#slice#every
core#slice#some
core#slice#filter
core#slice#find
0
func CountBy[T any](collection []T, predicate func(item T) bool) int

Counts the number of elements for which the predicate is true.

lo.CountBy([]int{1, 5, 1}, func(i int) bool {
    return i < 4
})
// 2