mirror of
https://github.com/samber/lo.git
synced 2026-04-22 23:47:11 +08:00
952 B
952 B
name, slug, sourceRef, category, subCategory, signatures, playUrl, variantHelpers, similarHelpers, position
| name | slug | sourceRef | category | subCategory | signatures | playUrl | variantHelpers | similarHelpers | position | |||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| GroupBy | groupby | it/seq.go#L244 | it | sequence |
|
https://go.dev/play/p/2TnGK6-zs |
|
|
80 |
Returns an object composed of keys generated from running each element of collection through a transform function. The value of each key is an array of elements responsible for generating the key.
Examples:
seq := func(yield func(string) bool) {
_ = yield("apple")
_ = yield("banana")
_ = yield("apricot")
_ = yield("blueberry")
}
grouped := it.GroupBy(seq, func(s string) string {
return string(s[0]) // group by first letter
})
// grouped contains map with keys: "a": ["apple", "apricot"], "b": ["banana", "blueberry"]