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

Description

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

Parameters

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

Return Value

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

Remarks

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

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

Related

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->>First($p => $p->$Name == "James");
printr $people->>First($p => $p->$Age == 25);

// PRINTS
// person Class
// (
//     [name] => James
//     [age] => 17
// )
// person Class
// (
//     [name] => Eddy
//     [age] => 25
// )

 


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