This is the legacy 4D documentation web site. Documentations are progressively being moved to developer.4d.com

Home

 
4D v19.8
collection.combine( )

collection.combine( ) 


 

collection.combine ( col2 {; index} ) -> Function result 
Parameter Type   Description
col2  Collection in Collection to combine
index  Longint in Position to which insert elements to combine in collection (default=length+1)
Function result  Collection in Original collection containing combined element(s)

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
Number: 805254

This command can be run in preemptive processes

 
PAGE CONTENTS 
 
HISTORY 

Created: 4D v16 R6

 
ARTICLE USAGE

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)