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

Description

Transforms elements in an array based on a specified query statement, similar to the functionality expected from a "Select" operation in LINQ.

Parameters

<array> The array to apply the transformation.
<queryStm> The query statement to evaluate and transform each array element.

Return Value

Success: Returns a new array containing the transformed elements.
Failure: Returns an empty array if the input array is empty or if the transformation yields no results.

Remarks

The Obtain function is designed to apply a transformation to each element in the array based on the provided 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->>Obtain($p => $p->$Name);
printr $people->>Obtain($p => $p->$Age);

// PRINTS
// Array
// (
//     [0] => Eddy
//     [1] => Tom
//     [2] => James
//     [3] => Charles
//     [4] => Mike
//     [5] => Steve
//     [6] => James
// )
// Array
// (
//     [0] => 25
//     [1] => 23
//     [2] => 17
//     [3] => 19
//     [4] => 27
//     [5] => 25
//     [6] => 42
// )

 


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