Skip to main content



Methods

ScriptCollections support a standard set of methods; you cannot add new methods to a collection instance.

Method NameReturn typeArgumentsDescription
AddIntegerelementAdds element to the end of the collection, returns element index
Insert<none>index, elementInserts element into the collection at specified index; if index is beyond the current bounds of the collection, default-valued elements will be inserted up to the point of index.
RemoveAt<none>indexRemoves element at specified index from the collection
Clear<none><none>Removes all elements from the collection
AddRange<none>anotherCollectionAdds elements in anotherCollection to current collection
InsertRange<none>index, anotherCollectionInserts elements in anotherCollection into the current collection at specified index; if index is beyond the current bounds of the collection, default-valued elements will be inserted up to the point of index.
RemoveRange<none>index, countRemoves count elements from the current collection, starting at index
Push<none>elementStack-like operation; pushes element into collection at index 0
Pop<varies><none>Stack-like operation; pops and returns element at index 0 off the collection
Enqueue<none>elementQueue-like operation; inserts element into head of collection (index 0)
Dequeue<varies><none>Queue-like operation; removes and returns last element in collection
ForEach<none>function or CLR delegateApplies function or delegate to each item in the collection: var sum = 0; var x = [ 1, 3, 6 ]; x.ForEach( function ( element ) { sum += element; } ); Function takes either one parameter (the element) or two parameters (the element index, and the element); it should return no value. Supported CLR delegate types are System.Action<object> and System.Action<int, object>. Adding or removing elements from the collection during ForEach iteration results in an error.
ReverseCollection<none>Returns a new collection with elements from the original collection in reverse order; the original collection is unmodified
FilterCollectionfunction or CLR delegateReturns a new collection of elements from the original collection that match a filter function or delegate: var x = [ 1, 3, 6 ]; var y = x.Filter( function ( item ) { if( item % 2 == 0 ) { return true; } else { return false; } } ); Function takes either one parameter (the element) or two parameters (the element index, and the element); it must return a boolean value. Supported CLR delegate types are System.Func<object, bool> and System.Func<int, object, bool>. Adding or removing elements from the collection during Filter processing results in an error.
TransformCollectionfunction or CLR delegateReturns a new collection of elements transformed by a function or delegate from the original collection: var x = [ 1, 3, 6 ]; var y = x.Transform( function ( item ) { return item.ToString(); } ); Function takes either one parameter (the element) or two parameters (the element index, and the element); it must return a value. Supported CLR delegate types are System.Func<object, object> and System.Func<int, object, object>. Adding or removing elements from the collection during Transform processing results in an error.
UnionCollectionsecondCollection, and optional equality function or equality delegateReturns a new collection representing the union of elements in the original collection and elements in secondCollection: var x = [1, 3, 5]; var y = [2, 4, 6]; var z = x.Union( y ); Duplicate values are not preserved in the new collection. By default, element equality is determined using the EqualityComparer<object>.Default implementation. A second parameter may be passed to supply custom equality comparison logic; this can either be a function taking one parameter and returning a computed hash value (integer) for that parameter, or a CLR delegate of type System.Func<object, int>.
IntersectCollectionsecondCollection, and optional equality function or equality delegateReturns a new collection representing the intersection of elements in the original collection and elements in secondCollection: var x = [1, 3, 5]; var y = [2, 4, 5]; var z = x.Intersect( y ); Duplicate values are not preserved in the new collection. By default, element equality is determined using the EqualityComparer<object>.Default implementation. A second parameter may be passed to supply custom equality comparison logic; this can either be a function (applied to each candidate element) taking one parameter and returning a computed hash value (integer) for that parameter, or a CLR delegate of type System.Func<object, int>.
GetRangeCollectionindex, countReturns a new collection of count elements from the original collection, beginning at index.
TrueForAllBooleanfunction or CLR delegateApplies a boolean function or delegate to all elements of the original collection, and returns a single boolean value indicating whether all elements return true for function or delegate: var x = [ 1, 3, 6 ]; var y = x.TrueForAll( function ( item ) { return item % 2 == 0; } ); Function takes either one parameter (the element) or two parameters (the element index, and the element); it must return a boolean value. Supported CLR delegate types are System.Func<object, boolean> and System.Func<int, object, boolean>. Adding or removing elements from the collection during processing results in an error.
TrueForAnyBooleanfunction or CLR delegateApplies a boolean function or delegate to all elements of the original collection, and returns a single boolean value indicating whether any element returns true for function or delegate: var x = [ 1, 3, 6 ]; var y = x.TrueForAny( function ( item ) { return item % 2 == 0; } ); Function takes either one parameter (the element) or two parameters (the element index, and the element); it must return a boolean value. Supported CLR delegate types are System.Func<object, boolean> and System.Func<int, object, boolean>. Adding or removing elements from the collection during processing results in an error.
OrderByCollectionfunction or CLR delegate, and optional comparison function or comparison delegateReturns a new collection of elements from the original collection, ordered by ascending key values generated by function or delegate: var x = ['hi', 'bye', 'cya']; var y = x.OrderBy( function(item) { return item[0]; } ); By default, key comparisons are performed using Comparer<object>.Default. A second parameter may be passed to supply custom comparison logic; this can either be a function taking two parameters and returning an integer (1 if parameter1 is greater, -1 if parameter2 is greater, or 0 if equal), or a CLR delegate of type System.Func<object, object, int>.