This version is out of date, covering development from v9.5.0 to v9.7.3. It is maintained here only for inbound reference links from elsewhere. It is no longer actively updated.

Jump to the current version of aTbRef

Tinderbox v9 Icon

List/Set.last()


Operator Type: 

Operator Scope of Action: 

Operator Purpose: 

Operator First Added: 

Operator Last Altered: 

 Property  [other Property type actions]

 List  [operators of similar scope]

 Dictionary, Set & List operations  [other Dictionary, Set & List operations operators]

 Baseline

 As at baseline


Syntax note: Operators without any defined mandatory arguments may omit their empty closing parentheses


List/Set.last()

List/Set.last

Returns the last item of a list. If MyList is a 5-item list "ant;bee;cow;dog;eel":

$MyString = $MyList.last; returns "eel"

This is also the equivalent of $MyList[-1] or $MyList.at(-1).

List/Set.last(N)

Returns a list of the last N items of a list. With the same list as above:

$MyList2 = $MyList.last(2); returns "dog;eel"

Testing for loop position

This operator can be used to test the current loop state, i.e. whether the currently processed item is the last in the list. Here the code in the commented section is run only when the last list item in $MyList is being processed:

	$MyList.each(anItem){
		if(anItem==$MyList.last){
			// some code here ...
		};
	};

Note that '$MyList.last' is not a test in itself. Rather, it supplies the value of the last list item which can be tested against the currently processed item.

See also List/Set.first.