Operator Type:
Operator Scope of Action:
Operator Purpose:
Data Type Returned:
Operator First Added:
Operator in Current Baseline:
Operator Last Altered:
Property [other Property type actions]
List [operators of similar scope]
Dictionary, Set & List operations [other Dictionary, Set & List operations operators]
source context dependent
v9.0.0
Baseline
As at baseline
Syntax note: Operators without any defined mandatory arguments may omit their empty closing parentheses
list.first()
list.first
Returns the first item of a List- or Set-type list. If MyList is a 5-item list "ant;bee;cow;dog;eel":
$MyString = $MyList.first; returns "ant"
This is also the equivalent of $MyList[0] or $MyList.at(0).
list.first(N)
Returns a list of the first N items of a list. With the same list as above:
$MyList2 = $MyList.first(2); returns "ant;bee"
Testing for loop position
This operator can be used to test the current loop state, i.e. whether the currently processed item is the first in the list. Here the code in the commented section is run only when the first list item in $MyList is being processed:
$MyList.each(anItem){
if(anItem==$MyList.first){
// some code here ...
};
};
Note that '$MyList.first' is not a test in itself. Rather, it supplies the value of the first list item which can be tested against the currently processed item.
See also list.last.
See also—notes linking to here: