This is the legacy 4D documentation web site. Documentations are progressively being moved to developer.4d.com |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
4D v19.8
collection.remove( )
|
collection.remove ( index {; howMany} ) -> Function result | ||||||||
Parameter | Type | Description | ||||||
index | Longint |
![]() |
Element at which to start removal | |||||
howMany | Longint |
![]() |
Number of elements to remove, or 1 element if omitted | |||||
Function result | Collection |
![]() |
Original collection without removed element(s) | |||||
The collection.remove( ) method removes one or more element(s) from the specified index position in the collection and returns the edited collection.
Note: This method modifies the original collection.
In index, pass the position where you want the element to be removed from the collection. Warning: Keep in mind that collection elements are numbered from 0. If index is greater than the length of the collection, actual starting index will be set to the length of the collection.
In howMany, pass the number of elements to remove from index. If howMany is not specified, then one element is removed.
If you try to remove an element from an empty collection, the method does nothing (no error is generated).
C_COLLECTION($col)
$col:=New collection("a";"b";"c";"d";"e";"f";"g";"h")
$col.remove(3) // $col=["a","b","c","e","f","g","h"]
$col.remove(3;2) // $col=["a","b","c","g","h"]
$col.remove(-8;1) // $col=["b","c","g","h"]
$col.remove(-3;1) // $col=["b","g","h"]
Product: 4D
Theme: Collections
Number:
705242
Created: 4D v16 R6
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)