This is the legacy 4D documentation web site. Documentations are progressively being moved to developer.4d.com |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
4D v19.8
collection.insert( )
|
collection.insert ( index ; element ) -> Function result | ||||||||
Parameter | Type | Description | ||||||
index | Longint |
![]() |
Where to insert the element | |||||
element | Expression |
![]() |
Element to insert in the collection | |||||
Function result | Collection |
![]() |
Original collection containing inserted element | |||||
The collection.insert( ) method inserts element at the specified index position in the collection instance and returns the edited collection.
Note: This method modifies the original collection.
In index, pass the position where you want the element to be inserted in the collection.
Warning: Keep in mind that collection elements are numbered from 0.
Any type of element accepted by a collection can be inserted, even another collection.
C_COLLECTION($col)
$col:=New collection("a";"b";"c";"d") //$col=["a","b","c","d"]
$col.insert(2;"X") //$col=["a","b","X","c","d"]
$col.insert(-2;"Y") //$col=["a","b","X","Y","c","d"]
$col.insert(-10;"Hi") //$col=["Hi","a","b","X","Y","c","d"]
Product: 4D
Theme: Collections
Created: 4D v16 R6
4D Language Reference ( 4D v19)
4D Language Reference ( 4D v19.1)
4D Language Reference ( 4D v19.4)
4D Language Reference ( 4D v19.5)
4D Language Reference ( 4D v19.6)
4D Language Reference ( 4D v19.7)
4D Language Reference ( 4D v19.8)