Back to Lo

Core Repeatby

docs/data/core-repeatby.md

1.53.0189 B
Original Source

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

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