mirror of
https://github.com/maaslalani/confetty.git
synced 2024-11-24 16:46: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))]
|
|
}
|