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
818 B
818 B
name, slug, sourceRef, category, subCategory, signatures, playUrl, variantHelpers, similarHelpers, position
| name | slug | sourceRef | category | subCategory | signatures | playUrl | variantHelpers | similarHelpers | position | ||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Times | times | it/seq.go#L202 | it | sequence |
|
https://go.dev/play/p/0W4IRzQuCEc |
|
|
70 |
Invokes a callback function n times and returns a sequence of the results.
Examples:
seq := it.Times(5, func(index int) int {
return index * 2
})
var result []int
for v := range seq {
result = append(result, v)
}
// result contains 0, 2, 4, 6, 8
seq := it.Times(3, func(index int) string {
return fmt.Sprintf("item-%d", index+1)
})
var result []string
for v := range seq {
result = append(result, v)
}
// result contains "item-1", "item-2", "item-3"