This is the legacy 4D documentation web site. Documentations are progressively being moved to developer.4d.com

Home

 
4D v19.8
collection.max( )

collection.max( ) 


 

collection.max ( {propertyPath} ) -> Function result 
Parameter Type   Description
propertyPath  Text in Object property path to be used for evaluation
Function result  Boolean, Text, Number, Collection, Object, Date in Maximum value in the collection

The collection.max( ) method returns the element with the highest value in the collection (the last element of the collection as it would be sorted in ascending order using the collection.sort( ) method).

Note: This method does not modify the original collection.

If the collection contains different types of values, the max( ) function will return the maximum value within the last element type in the type list order (see collection.sort( ) description).

If the collection contains objects, pass the propertyPath parameter to indicate the object property whose maximum value you want to get.

If the collection is empty, collection.max( ) returns Undefined.

Example  

 C_COLLECTION($col)
 $col:=New collection(200;150;55)
 $col.push(New object("name";"Smith";"salary";10000))
 $col.push(New object("name";"Wesson";"salary";50000))
 $col.push(New object("name";"Alabama";"salary";10500))
 $max:=$col.max() //{name:Alabama,salary:10500}
 $maxSal:=$col.max("salary") //50000
 $maxName:=$col.max("name") //"Wesson"



See also 

collection.min( )

 
PROPERTIES 

Product: 4D
Theme: Collections
Number: 805288

This command can be run in preemptive processes

 
PAGE CONTENTS 
 
HISTORY 

Created: 4D v16 R6

 
ARTICLE USAGE

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)