Operator Type:
Operator Scope of Action:
Operator Purpose:
Data Type Returned:
Operator First Added:
Operator in Current Baseline:
Operator Last Altered:
Function [other Function type actions]
List [operators of similar scope]
Dictionary, Set & List operations [other Dictionary, Set & List operations operators]
source context dependent
v9.5.2
Baseline
As at baseline
Syntax note: Operators without any defined mandatory arguments may omit their empty closing parentheses
list.randomItem()
The .randomItem() returns a randomly-selected item from a List- or Set-type list:
$MyString = $MyList.randomItem();
This replaces the extra coding needed for such a task if using rand().
This operator can be used not only on attributes but also literal lists using list():
$MyString = list("ant;bee;cow;dog").randomItem();
list-based variables:
var:list vList = "ant;bee;cow;dog"; $MyString = vList.randomItem();
and list-creating operators:
$MyString = collect(find($SomeAttribute=="xyz"),$Path).randomItem();
See also—notes linking to here: