Lists are similar tables
which can contain nil
items without shortening the length.
They also have a few additional methods to assist with managing the size.
- Constructors - API calls which return an object, typically one that offers API methods
- of
- sized
- Methods - API calls which can only be made on an object returned by a constructor
- size
- trim
Signature |
cp.collect.List.of(...) -> cp.collect.List |
Type |
Constructor |
Description |
Creates a new List with the specified items init. |
Parameters |
- ... - The items to put in the list, in order.
|
Returns |
|
Signature |
cp.collect.List.sized([size[, defaultValue]]) -> cp.collect.List |
Type |
Constructor |
Description |
Creates a new List with the specified size. |
Parameters |
- size - The size of the list. Defaults to
0 . - defaultValue - If specified, all items in the list will be initialised to the default value.
|
Returns |
|
Signature |
cp.collect.List:size([newSize]) -> number |
Type |
Method |
Description |
Returns and/or sets the current size of the list. |
Parameters |
- newSize - if provided, sets the new size of the list. Any values contained above the new size are set to
nil .
|
Returns |
|
Signature |
cp.collect.List:trim([minSize]) -> cp.collect.List |
Type |
Method |
Description |
Trims the current List to only contain trailing values that are not nil . |
Parameters |
- minSize - If provided, the minimum size to trim down to. Defaults to
0 .
|
Returns |
|