mirror of
https://github.com/samber/lo.git
synced 2026-04-22 23:47:11 +08:00
828 B
828 B
name, slug, sourceRef, category, subCategory, signatures, playUrl, variantHelpers, similarHelpers, position
| name | slug | sourceRef | category | subCategory | signatures | playUrl | variantHelpers | similarHelpers | position | |||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| MinBy | minby | it/find.go#L242 | it | find |
|
https://go.dev/play/p/5CwPTPz-zb |
|
|
140 |
Searches minimum value using a custom comparison function. The comparison function should return true if the first argument is "less than" the second.
Examples:
type Person struct {
Name string
Age int
}
seq := func(yield func(Person) bool) {
_ = yield(Person{"Alice", 30})
_ = yield(Person{"Bob", 25})
_ = yield(Person{"Charlie", 35})
}
youngest := it.MinBy(seq, func(a, b Person) bool {
return a.Age < b.Age
})
// youngest == Person{"Bob", 25}