4D v17.4

collection.resize( )

Home

 
4D v17.4
collection.resize( )

collection.resize( )  


 

The collection.resize( ) method sets the collection length to the specified new size and returns the resized collection.

Note: This method modifies the original collection.

  • If size < collection length, exceeding elements are removed from the collection.
  • If size > collection length, the collection length is increased to size.
    By default, new elements are filled will null values. You can specify the value to fill in added elements using the defaultValue parameter.

Example  

 C_COLLECTION($c)
 $c:=New collection
 $c.resize(10) // $c=[null,null,null,null,null,null,null,null,null,null]
 
 $c:=New collection
 $c.resize(10;0) // $c=[0,0,0,0,0,0,0,0,0,0]
 
 $c:=New collection(1;2;3;4;5)
 $c.resize(10;New object("name";"X")) //$c=[1,2,3,4,5,{name:X},{name:X},{name:X},{name:X},{name:X}]
 
 $c:=New collection(1;2;3;4;5)
 $c.resize(2) //$c=[1,2]



See also 

collection.fill( )
collection.length

 
PROPERTIES 

Product: 4D
Theme: Collections

This command can be run in preemptive processes

 
PAGE CONTENTS 
 
HISTORY 

 
ARTICLE USAGE

4D Language Reference ( 4D v17)
4D Language Reference ( 4D v17.1)
4D Language Reference ( 4D v17.2)
4D Language Reference ( 4D v17.3)
4D Language Reference ( 4D v17.4)