ArrayToList
Used to iterate over an array and run the function closure for each item in the array.
Method Signature
ArrayToList(array=[array], delimiter=[String], initialValue=[any])
Arguments
Argument
Type
Required
Description
Default
array
array
true
The array to join together
delimiter
String
false
The character to use as a separator
,
initialValue
any
false
Examples
Retrieve an array as a list
Uses the arrayToList function with a pipe delimiter to retrieve an array as a list
someArray = [
1,
2,
3,
4
];
someList = arrayToList( someArray, "|" );
writeOutput( someList );
Result: "1|2|3|4"
Retrieve an array as a list using the Array member function
Uses the Array member function to retrieve an array as a list
seinfeldArray = [
"Jerry",
"Elaine",
"Kramer",
"George"
];
seinfeldList = seinfeldArray.toList();
writeOutput( seinfeldList );
Result: "Jerry,Elaine,Kramer,George"
Additional Examples
newArray = [
"a",
"b",
"c",
"b",
"d",
"b",
"e",
"f"
];
dump( arrayToList( newArray ) );
// member function, with custom separator
dump( newArray.toList( "--" ) );
Related
Last updated
Was this helpful?