"Sputnik" help  
Sputnik Help
Last(<array>, <queryStm>)

Description

Returns the last element in an array that satisfies a specified query statement.

Parameters

<array> The array to search for the last matching element.
<queryStm> The query statement to evaluate each array element.

Return Value

Success: Returns the last element that satisfies the query statement.
Failure: Returns null if no matching element is found.

Remarks

The Last function is particularly useful when searching for the last element in an array that meets specific criteria defined by the query statement.

Related

Make sure to read about the ->> and the =>> operators which are very often used in Linq statements.

Example

Example of usage:

Class Person
{
    my $Name;
    my $Age;
    Function __Construct($Name, $Age)
    {
        @this->$Name = $Name;
        @this->$Age = $Age;
    }
}
my $people = array(
                new Person("Eddy", 25),
                new Person("Tom", 23),
                new Person("James", 17),
                new Person("Charles", 19),
                new Person("Mike", 27),
                new Person("Steve", 25),
                new Person("James", 42),
                );
                
printr $people->>Last($p => $p->$Name == "James");
printr $people->>Last($p => $p->$Age == 25);

// PRINTS
// person Class
// (
//     [name] => James
//     [age] => 42
// )
// person Class
// (
//     [name] => Steve
//     [age] => 25
// )

 


Contact
Cheryl (uberfox@hotmail.com)
Homepage
http://ubersoft.org