duplicate
Table of Contents
Overview
The duplicate function returns the elements present in the given start index (inclusive) and end index (non inclusive). If the indices are not specified, it duplicates and returns the given collection of elements.
Return Type
- LIST
Syntax
<variable> = <collectionVariable>.duplicate(<startIndex>, <endIndex>);
where,
Parameter | Data type | Description |
<variable> | LIST | Variable which will hold the returned list. |
<collectionVariable> | COLLECTION | Variable from which the elements in the specified indices will be returned. |
<startIndex> <endIndex> (optional) | NUMBER | The start and end indices of the elements which needs to be duplicated. Index starts from 0. If the value for endIndex is greater than the list size, a runtime error will be encountered. If the indices are not specified, the function duplicates and returns the entire list. |
Examples
products1 = collection("Creator", "CRM", "Books"); info products1.duplicate( 0, 1); // Returns "Creator"