mirror of
https://github.com/maaslalani/confetty.git
synced 2024-11-15 04:06:43 +00:00
9 lines
158 B
Go
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))]
|
|
}
|