Files
lo/docs/data/core-countby.md
T
Samuel Berthe fa095e4b4f fix(doc): fix go playground demo URL (#832)
* fix(doc): fix go playground demo URL

* fix(doc): add more go playground demo URL
2026-03-06 00:09:59 +01:00

570 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#L849 core slice https://go.dev/play/p/5GMQP5vNT4q
core#slice#countby
core#slice#count
core#slice#every
core#slice#some
core#slice#filter
core#slice#find
core#slice#countbyerr
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