Accumulates a value by passing elements of an array “through” a function.
Data passed to the function on each iteration,
_array | Array of key-value pairs to create Hash from [Array] |
_initial | Initial value to pass into the function as _accumulator [Any] |
_function | Code to pass values to [Function] |
Accumlated value [Any]
_result = [[1, 2, 3], "", { _accumulator + (str _x) }] call CBA_fnc_inject; // _result ==> "123" _result = [[1, 2, 3], " frogs", { (str _x) + _accumulator }] call CBA_fnc_inject; // _result ==> "321 frogs" _result = [[1, 2, 3], 0, { _accumulator + _x }] call CBA_fnc_inject; // _result ==> 6
Spooner