Skip to content

Commit

Permalink
doc: improves example of RepeatBy
Browse files Browse the repository at this point in the history
  • Loading branch information
samber committed Jul 29, 2022
1 parent a4816ee commit cf45927
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -510,13 +510,13 @@ slice := lo.Repeat[foo](2, foo{"a"})
Builds a slice with values returned by N calls of callback.

```go
slice := lo.RepeatBy[int](0, func (i int) int {
return math.Pow(i, 2)
slice := lo.RepeatBy[string](0, func (i int) string {
return strconv.FormatInt(math.Pow(i, 2), 10)
})
// []int{}

slice := lo.RepeatBy[int](5, func (i int) int {
return math.Pow(i, 2)
slice := lo.RepeatBy[string](5, func (i int) string {
return strconv.FormatInt(math.Pow(i, 2), 10)
})
// []int{0, 1, 4, 9, 16}
```
Expand Down

0 comments on commit cf45927

Please sign in to comment.