arraySum

The sum of values in an array. If the array parameter value is
an empty array, returns zero.

arraySum(array) → returns numeric

Member Function Syntax

someArray.sum()

arraySum Argument Reference

array array
Required

An array name or variable name

ignoreEmpty boolean
Default: false

CF 2016.0.3+ Whether to ignore empty string or null values

Examples sample code invoking the arraySum function

Uses the arraySum function to get sum of values in an array

numberArray = [10,99,27,72];
writeOutput( arraySum(numberArray));

Expected Result: 208

To get sum of values in an empty array

numberArray = [];
writeOutput( arraySum(numberArray));

Expected Result: 0

CF 11+ Lucee 4.5+ Uses the sum member function is the same as running arraySum.

numberArray = [10,99,27,72];
writeOutput( numberArray.sum() );

Expected Result: 208


Fork me on GitHub