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

Home

 
4D v19.8
collection.fill( )

collection.fill( ) 


 

collection.fill ( value {; startFrom {; end}} ) -> Function result 
Parameter Type   Description
value  Number, Text, Collection, Object, Date, Boolean in Filling value
startFrom  Longint in Start index (included)
end  Longint in End index (not included)
Function result  Collection in Original collection with filled values

The collection.fill( ) method fills the collection with the specified value, optionally from startFrom index to end index, and returns the resulting collection.

Note: This method modifies the original collection.

  • If the startFrom parameter is omitted, value is set to all collection elements (startFrom=0). If the end parameter is omitted, the value is set to the last element of the collection (end=length).
  • If startFrom < 0, it is recalculated as startFrom:=startFrom+length (it is considered as the offset from the end of the collection). If the calculated value is negative, startFrom is set to 0.
  • If end < 0 , it is recalculated as end:=end+length.
  • If end < startFrom (passed or calculated values), the method does nothing. 

Example  

 C_COLLECTION($c)
 $c:=New collection(1;2;3;"Lemon";Null;"";4;5)
 $c.fill("2") // $c:=[2,2,2,2,2,2,2,2]
 $c.fill("Hello";5) // $c=[2,2,2,2,2,Hello,Hello,Hello]
 $c.fill(0;1;5) // $c=[2,0,0,0,0,Hello,Hello,Hello]
 $c.fill("world";1;-5) //-5+8=3 -> $c=[2,"world","world",0,0,Hello,Hello,Hello]



See also 

collection.resize( )

 
PROPERTIES 

Product: 4D
Theme: Collections
Number: 805262

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)