This is the legacy 4D documentation web site. Documentations are progressively being moved to developer.4d.com |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
4D v19.8
collection.slice( )
|
collection.slice ( startFrom {; end} ) -> Function result | ||||||||
Parameter | Type | Description | ||||||
startFrom | Longint |
![]() |
Index to start the search at (included) | |||||
end | Longint |
![]() |
End index (not included) | |||||
Function result | Collection |
![]() |
New collection containing sliced elements (shallow copy) | |||||
The collection.slice( ) method returns a portion of a collection into a new collection, selected from startFrom index to end index (end not included). This method returns a shallow copy of the collection. If the original collection is a shared collection, the returned collection is also a shared collection.
Note: This method does not modify the original collection.
The returned collection contains the element specified by startFrom and all subsequent elements up to, but not including, the element specified by end. If only the startFrom parameter is specified, the returned collection contains all elements from startFrom to the last element of the original collection.
C_COLLECTION($c;$nc)
$c:=New collection(1;2;3;4;5)
$nc:=$c.slice(0;3) //$nc=[1,2,3]
$nc:=$c.slice(3) //$nc=[4,5]
$nc:=$c.slice(1;-1) //$nc=[2,3,4]
$nc:=$c.slice(-3;-2) //$nc=[3]
Product: 4D
Theme: Collections
Number:
805250
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)