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]
Item [operators of similar scope]
Data manipulation [other Data manipulation operators]
source context dependent
v5.7.1
Baseline
As at baseline
list.at(itemNum)
This returns the value of item itemNum of the List- or Set-type list as a string. List can be either Set or List type attributes (or string literal, regex, or expression equivalents thereof). This operator is read-only: list values can be read, but not set.
Note: for accessing look-up tables, use list.lookup().
The operator is zero-based, i.e. an itemNum value of 0 returns the first list item, an itemNum of 1 returns value #2, etc. If the value of N exceeds the number of items in the list an empty string (blank value) is returned. A negative number returns an item numbering in reverse, but one-based not zero-based, so '-1' returns the last item on the list, '-2' the last but one item, etc.
Examples (where $MyList is "ant;bee;cow"):
$MyString = $MyList.at(0); returns "ant"
$MyString = "XX;YY;ZZ".at(2); returns "ZZ"
$MyString = $MyList.at(5); returns "" (nothing)
$MyString = $MyList.at(-2); returns "bee"
See also the more recent list[N] usage.
To address particular locations in a list, also see list.first(), list.last() and list.randomItem().
Legacy use (pre-v8)
list.at("key")
This usage is deprecated, use list.lookup("key") instead. The remainder of this section is for explanation of legacy code use only.
The .at() function is also useful for accessing values from look-up tables by providing the relevant key. Consider a look-up list:
$RegionList="AL:South;AK:NorthWest;default:North";
This allows actions like:
$Region=$RegionList.at("AL");
or
$Region=$RegionList.at($State);
See also—notes linking to here: