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

Home

 
4D v19.8
collection.unshift( )

collection.unshift( ) 


 

collection.unshift ( value {; value2 ; ... ; valueN} ) -> Function result 
Parameter Type   Description
value  Expression in Value(s) to insert at the beginning of the collection
Function result  Collection in Collection containing added element(s)

The collection.unshift( ) method inserts the given value(s) at the beginning of the collection and returns the modified collection.

Note: This method modifies the original collection.

If several values are passed, they are inserted all at once, which means that they appear in the resulting collection in the same order as in the argument list.

Example  

 C_COLLECTION($c)
 $c:=New collection(1;2)
 $c.unshift(4) // $c=[4,1,2]
 $c.unshift(5) //$c=[5,4,1,2]
 $c.unshift(6;7) // $c=[6,7,5,4,1,2]



See also 

collection.pop( )
collection.shift( )

 
PROPERTIES 

Product: 4D
Theme: Collections

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)