This is the legacy 4D documentation web site. Documentations are progressively being moved to developer.4d.com |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
4D v19.8
collection.map( )
|
collection.map ( methodName {; param}{; param2 ; ... ; paramN} ) -> Function result | ||||||||
Parameter | Type | Description | ||||||
methodName | Text |
![]() |
Name of method used to transform the collection elements | |||||
param | Expression |
![]() |
Parameter(s) for the method | |||||
Function result | Collection |
![]() |
Collection of transformed values | |||||
The collection.map( ) method creates a new collection based upon the result of the call of the methodName method on each element of the original collection. Optionally, you can pass parameters to methodName using the param parameter(s). collection.map( ) always returns a collection with the same size as the original collection.
Note: This method does not modify the original collection.
methodName receives the following parameters:
methodName sets the following parameter(s):
C_COLLECTION($c;$c2)
$c:=New collection(1;4;9;10;20)
$c2:=$c.map("Percentage";$c.sum())
//$c2=[2.27,9.09,20.45,22.73,45.45]
Here is the Percentage method:
C_OBJECT($1)
C_REAL($2)
$1.result:=Round(($1.value/$2)*100;2)
Product: 4D
Theme: Collections
Number:
805252
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)