Returns a random element from the array.
Uses the cryptographically secure random number generator to select an element.
element(array, n?)
array
The array to select an element from.
Can be of any type that is indexable with [].
n optional
The number of elements to select.
If not given, returns a single element.
If given, returns an array of n elements, each sampled individually
(that is, the same element may be selected multiple times).
An randomly selected element from the array, or an array of randomly selected elements.
random.element(["coffee", "tea", "water"])
"tea"
random.element(["coffee", "tea", "water"], 3)
["coffee", "coffee", "water"]