Returns a ->subSequence of the last integer entities in the collection <Sequence>. Another operator, such as ->sortedBy or ->sortedByDesc, must be used to transform a <Collection> into a <Sequence> before ->last can be used. <Sequence> must be expressed as a unique alias. If integer is larger than the number of entities in the collection, all the entities in the collection are returned. See Advanced Collection Syntax for more examples of usage.
This sample Rulesheet uses ->last(2) to select the last two elements of the sequence created by applying ->sortedBy to collection2. Once identified, the last 2 entities will be returned as the sequence collection3.
SAMPLE RULETEST
A sample Ruletest provides a collection of five elements, each with a decimal1 value. Input and Output panels are shown below.
Note: The selected entities and their values are highlighted to improve readability.
RULESHEET EXAMPLE: SAME COLLECTION
In this example, the action uses the same collection for the source and the target:
SAMPLE RULETEST: SAME COLLECTION
The sample Ruletest shows the last 2 entities are retained in the collection, and the extraneous entities are moved out of the collection to root level:
Note: Using the same collection as the source and the target is an important consideration because the original collection cannot be accessed again, and another iteration using this operator would likely produce a different result.