mirror of
https://github.com/samber/lo.git
synced 2026-04-22 23:47:11 +08:00
662 B
662 B
name, slug, sourceRef, category, subCategory, signatures, playUrl, variantHelpers, similarHelpers, position
| name | slug | sourceRef | category | subCategory | signatures | playUrl | variantHelpers | similarHelpers | position | ||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| SumBy | sumby | it/math.go#L74 | it | math |
|
|
|
65 |
Returns the sum of values in the collection using the given transform function.
type Person struct {
Name string
Age int
}
people := it.Slice([]Person{
{"Alice", 25},
{"Bob", 30},
{"Charlie", 35},
})
result := it.SumBy(people, func(p Person) int {
return p.Age
})
// 90