mirror of
https://github.com/maaslalani/confetty.git
synced 2024-11-22 07:36:40 +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))]
|
|
}
|