mirror of
https://github.com/samber/lo.git
synced 2026-04-22 23:47:11 +08:00
fa095e4b4f
* fix(doc): fix go playground demo URL * fix(doc): add more go playground demo URL
791 B
791 B
name, slug, sourceRef, category, subCategory, variantHelpers, playUrl, similarHelpers, position, signatures
| name | slug | sourceRef | category | subCategory | variantHelpers | playUrl | similarHelpers | position | signatures | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| TakeWhile | takewhile | slice.go#L605 | core | slice |
|
https://go.dev/play/p/NJkLGvyRWm4 |
|
195 |
|
Takes elements from the beginning while the predicate returns true.
lo.TakeWhile([]int{0, 1, 2, 3, 4, 5}, func(val int) bool {
return val < 3
})
// []int{0, 1, 2}
lo.TakeWhile([]string{"a", "aa", "aaa", "aa"}, func(val string) bool {
return len(val) <= 2
})
// []string{"a", "aa"}