randomItem<T> static method
Picks a random item from iterable
and returns it.
Uses randomInt internally to select an item index.
An instance of Math.Random can optionally be passed to customize the random sample distribution.
Implementation
static T randomItem<T>(Iterable<T> iterable, [Math.Random? random]) {
random = random ?? Math.Random();
return iterable.elementAt(
randomInt(0, iterable.length, random),
);
}