4D v19

collection.combine( )

Home

 
4D v19
collection.combine( )

collection.combine( )  


 

The collection.combine( ) method inserts col2 elements at the end or at the specified index position in the collection instance and returns the edited collection. Unlike the collection.insert( ) method, collection.combine( ) adds each value of col2 in the original collection, and not as a single collection element.

Note: This method modifies the original collection.

By default, col2 elements are added at the end of the orginal collection. You can pass in index the position where you want the col2 elements to be inserted in the collection. Warning: Keep in mind that collection elements are numbered from 0.

  • If index > the length of the collection, the actual starting index will be set to the length of the collection.
  • If index < 0, it is recalculated as index:=index+length (it is considered as the offset from the end of the collection).
  • If the calculated value is negative, index is set to 0.

Example  

 C_COLLECTION($c;$fruits)
 $c:=New collection(1;2;3;4;5;6)
 $fruits:=New collection("Orange";"Banana";"Apple";"Grape")
 $c.combine($fruits;3) //[1,2,3,"Orange","Banana","Apple","Grape",4,5,6]



See also 

collection.concat( )
collection.insert( )

 
PROPERTIES 

Product: 4D
Theme: Collections

This command can be run in preemptive processes

 
PAGE CONTENTS 
 
HISTORY 

 
ARTICLE USAGE

4D Language Reference ( 4D v19)
4D Language Reference ( 4D v19.1)