Files
lo/docs/data/core-repeatby.md
T
2026-03-02 16:06:51 +01:00

555 B

name, slug, sourceRef, category, subCategory, playUrl, variantHelpers, similarHelpers, position, signatures
name slug sourceRef category subCategory playUrl variantHelpers similarHelpers position signatures
RepeatBy repeatby slice.go#L362 core slice https://go.dev/play/p/ozZLCtX_hNU
core#slice#repeatby
core#slice#repeatbyerr
core#slice#times
core#slice#repeat
220
func RepeatBy[T any](count int, callback func(index int) T) []T

Builds a slice by calling the callback N times with the current index.

lo.RepeatBy(5, func(i int) string {
    return strconv.Itoa(i * i)
})
// []string{"0", "1", "4", "9", "16"}