Back to Lo

Core Sampleby

docs/data/core-sampleby.md

1.53.0175 B
Original Source

Returns a random item from a collection, using the provided random index generator.

go
v := lo.SampleBy([]int{10, 20, 30}, func(n int) int {
    return 0
})
// v == 10