Class: Tuple

types~Tuple(…args)

Represents a sequence of immutable objects.

Tuples are sequences, just like Arrays. The only difference is that tuples are read only.

As tuples can be used as Map keys, the {toString} method calls toString for each element, trying to get a unique string key.

Constructor

new Tuple(…args)

Creates a new instance of Tuple.

Parameters:
Name Type Attributes Description
args any <repeatable>
Source:

Members

(readonly) elements :Array

Returns elements of the tuple.

Type:
  • Array
Source:

(readonly) length :Number

Returns the number of the elements.

Type:
  • Number
Source:

Methods

get(index)

Returns value located at the given index.

Parameters:
Name Type Description
index Number

Element index

Source:

toJSON() → {Array}

Returns an Array representation of the sequence.

Source:
Returns:
Type
Array

toString() → {string}

Returns a string representation of the sequence, surrounded by parenthesis, ie: (1, 2).

The returned value attempts to be a unique string representation of its values.

Source:
Returns:
Type
string

values() → {Array}

Gets the elements as an Array.

Source:
Returns:
Type
Array

(static) fromArray(elements) → {Tuple}

Creates a new instance of Tuple from an Array.

Parameters:
Name Type Description
elements Array
Source:
Returns:
Type
Tuple