This is the legacy 4D documentation web site. Documentations are progressively being moved to developer.4d.com |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
4D v19.8
collection.distinct( )
|
collection.distinct ( {propertyPath}{;}{option} ) -> Function result | ||||||||
Parameter | Type | Description | ||||||
propertyPath | Text |
![]() |
Path of attribute whose distinct values you want to get | |||||
option | Longint |
![]() |
ck diacritical: diacritical evaluation ("A" # "a" for example) | |||||
Function result | Collection |
![]() |
New collection with only distinct values | |||||
The collection.distinct( ) method returns a collection containing only distinct (different) values from the original collection.
Note: This method does not modify the original collection.
The returned collection is automatically sorted. Null values are not returned.
If the collection contains objects, you can pass the propertyPath parameter to indicate the object property whose distinct values you want to get.
By default, a non-diacritical evaluation is performed. If you want the evaluation to be case sensitive or to differentiate accented characters, pass the ck diacritical constant in the option parameter.
C_COLLECTION($c;$c2)
$c:=New collection
$c.push("a";"b";"c";"A";"B";"c";"b";"b")
$c.push(New object("size";1))
$c.push(New object("size";3))
$c.push(New object("size";1))
$c2:=$c.distinct() //$c2=["a","b","c",{"size":1},{"size":3},{"size":1}]
$c2:=$c.distinct(ck diacritical) //$c2=["a","A","b","B","c",{"size":1},{"size":3},{"size":1}]
$c2:=$c.distinct("size") //$c2=[1,3]
Product: 4D
Theme: Collections
Number:
805263
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)