Last NUMBER
- Last Updated: November 6, 2023
- 2 minute read
- Corticon
- Version 6.3
- Documentation
SYNTAX
<Sequence> ->last(integer)
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 sorting syntax
for more examples of usage.
The Operators row of the table in Vocabulary usage restrictions does not apply. Special exceptions: last(x) may only be used in Action Rows (section 5 in Sections of Rulesheet that correlate with usage restrictions).
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.
A sample Ruletest provides a collection of five elements, each with a
decimal1 value. Input and Output panels are
shown below.
In this example, the action uses the same collection for the source and the target:
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: