Skip to content
This repository has been archived by the owner on Jun 9, 2023. It is now read-only.

Latest commit

 

History

History
52 lines (42 loc) · 3.86 KB

cp.collect.List.md

File metadata and controls

52 lines (42 loc) · 3.86 KB

docs » cp.collect.List


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.

API Overview

  • 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

API Documentation

Constructors

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
  • The new List instance.
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
  • The new List instance.

Methods

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
  • The size of the list.
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
  • The same List instance.