confetty/array/array.go
2022-04-16 14:20:15 -04:00

9 lines
158 B
Go

package array
import "math/rand"
// Sample returns a random element from a generic array
func Sample[T any](arr []T) T {
return arr[rand.Intn(len(arr))]
}