A tuple is a sequence of immutable objects. Tuples are sequences, just like Arrays. The only difference is that tuples can’t be changed.

As tuples can be used as a Map keys, the toString() method calls toString of each element, to try to get a unique string key.

Members

Number

length

Returns the number of the elements.

Constructor

new

Tuple

([arguments])

Creates a new sequence of immutable objects with the parameters provided.

Parameters:
Name Type Description
arguments optional

The sequence elements as arguments.

Methods

Tuple.fromArray

(Array elements)

Creates a new instance of a tuple based on the Array

Static
This function is static
Parameters:
Name Type Description
elements Array
Returns:
Type Description
Tuple

get

(Number index)

Returns the value located at the index.

Parameters:
Name Type Description
index Number

Element index

toJSON

()

Returns the Array representation of the sequence.

Returns:
Type Description
Array

toString

()

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

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

Returns:
Type Description
string

values

()

Gets the elements as an array

Returns:
Type Description
Array