4D v19

collection.distinct( )

Home

 
4D v19
collection.distinct( )

collection.distinct( )  


 

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.

Example  

 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]

 
PROPERTIES 

Product: 4D
Theme: Collections

This command can be run in preemptive processes

 
PAGE CONTENTS 
 
HISTORY 

 
ARTICLE USAGE

4D Language Reference ( 4D v19)
4D Language Reference ( 4D v19.1)