Files
lo/docs/data/core-countvaluesby.md
T
Nathan Baulch e7386d9246 lint: fix inconsistent callback function parameter names (#730)
* Fix linting

* Use is.ElementsMatch

This will ignore the ordering of the final intersection. Especially
important when checking old versions of go that do not guarantee an order
when iterating through maps.

* lint: fix inconsistent callback function parameter names

* lint: rename "iteratee" to "transform" for *Map helpers

* lint: rename "project" parameters to "transform"

* lint: rename "cb" parameters to "callback"

* lint: rename "iteratee" to "callback" for ForEach helpers

---------

Co-authored-by: Franky W. <frankywahl@users.noreply.github.com>
Co-authored-by: Samuel Berthe <dev@samuel-berthe.fr>
2025-11-06 18:05:11 +01:00

657 B

name, slug, sourceRef, category, subCategory, playUrl, variantHelpers, similarHelpers, position, signatures
name slug sourceRef category subCategory playUrl variantHelpers similarHelpers position signatures
CountValuesBy countvaluesby slice.go#L623 core slice https://go.dev/play/p/2U0dG1SnOmS
core#slice#countvaluesby
core#slice#countvalues
core#slice#groupby
core#slice#map
core#slice#mapvalues
0
func CountValuesBy[T any, U comparable](collection []T, transform func(item T) U) map[U]int

Counts the number of each transformed value (equivalent to Map followed by CountValues).

isEven := func(v int) bool {
    return v%2 == 0
}
lo.CountValuesBy([]int{1, 2, 2}, isEven)
// map[bool]int{false: 1, true: 2}