Query criteria
|
Description
|
Example and result
|
array.Add(object)
|
Adds an object to the end of the array
|
|
array.Convert(expression, [object])
|
Changes the value of each element of the array to the result of evaluation of the given expression
|
array(1,2,3,4).convert ($item * 2)
Yields array(2, 4, 6, 8)
|
array.Count()
|
Returns the number of elements in the array
|
array(1,2,3).count
Yields 3
|
array.Empty()
|
Returns True if the array contains no elements
|
array(1,2,3).empty
Yields False
|
|
|
array().empty
Yields True
|
array.Filter(expression, [object])
|
Creates a subset of array elements by including only the elements for which the specified Boolean expression evaluates to True. The expression can use the same iterator object as in the ForEach method to get the value of the current element and the custom data passed in as the second parameter.
|
array(1,2,3,4,5).filter($item > 3)
Yields array(4, 5)
|
array.Find(object)
|
Finds an object in the array and returns True if it is found
|
array(1,2,3,4).find(3)
Yields True
|
array.ForEach(object, expression, [object])
|
Evaluates the specified expression for each element of the array and returns the result of the evaluation. This is an iterative process; the result of evaluation of the previous iteration is passed to the current one.
|
array(1,2,3,4).foreach (0, $lasteval + $item)
Yields the sum of all array elements: 10
|
|
The expression being evaluated can use a special iterator object, which has the following member variables:
• |
|
$item the current
array element
|
• |
|
$index the 1-based
index of the current
array element
|
• |
|
$lasteval the result
of evaluation of the
previous iteration
|
• |
|
$data additional
data object passed in
by the caller
|
|
array('this','is','an', 'example').foreach ('Result:', $lasteval + ' ' + $item.ToTitle)
Yields Result: This Is An Example
|
|
The first parameter specifies the initial value passed in through the $lasteval variable to the first element iteration. The second parameter is the expression being evaluated for each array element. The last optional parameter is the additional data object passed in as the $data variable; if this parameter is omitted, $data variable will contain a null object.
|
|
array.IndexOf(object)
|
Finds an object in the array and returns the 1-based index of the array element found, or 0 if not found
|
array('apple','orange','pear').indexof ('orange')
Yields 2
|
array.Item(int)
|
Gets the object identified by the index. The index is 1-based.
|
array(1,3,4).item(2)
Yields 3
|
array.Join(string)
|
Joins the array elements into a string by using the specified delimiter string
|
array(1,3,4).join(', ')
Yields '1, 3, 4'
|