choice

This function returns a pseudo-random item from a list or tuple . The array must contain at least one item, otherwise a lookup_err() is raised.

This function does not generate an event.

Function

array.choice()

Arguments

None

Return value

A pseudo-random item from the array.

Example

This code shows an example using choice():

// Returns either `a`, `b` or `c`
['a', 'b', 'c'].choice();

Example return value in JSON format

"b"