map<functionName>(__iterable);
function functionName(__value) {}
Description
Apply a function to each element of a collection (or other iterable variable). Returns an iterable containing the values returned by the applied function.
The function argument should be a function accepting a single argument.
When the argument to map is an OBJECT
, the mapping function will be passed an OBJECT
with a single key-value pair.
Example
use System, String; // Prints 5, 4, 3, 2, 1 print(map<flip>([1,2,3,4,5])); // Flips the values in the list function flip(item) { return 6 - item; } // Prints an iterator function print(items) { var list = []; foreach(item in items) { list[] = item; } System.print(String.join(list, ", ")); }