A tuple is an immutable list of at least two components. Components of the tuple are indexed from zero and indices must be of type Int. A tuple can be built with two or more components between ( and ).
Methods
at(index)
Get the component at index. index can be negative to indicate a position from the end, -1 being the last element. index must be valid.
def t = (1, 'a', 3.14, "good", true)
IO.println(t.at(3)) #> good
IO.println(t.at(-1)) #> true
See also: [ index ] operator
iterate(iterator), iterator_value(iterator)
Implement the iterator protocol to iterate over the components of the tuple.
size
Return the number of components in the tuple.
def t = (1, 'a', 3.14, "good", true)
IO.println(t.size) #> 5
to_s
Transform the tuple to a String.
def t = (1, 'a', 3.14, "good", true)
IO.println(t.to_s) #> (1, a, 3.14, good, true)
Operators
[ index ] operator
Get the component at index. index can be negative to indicate a position from the end, -1 being the last element. If index is not valid, nil is returned.
def t = (1, 'a', 3.14, "good", true)
IO.println(t[3]) #> good
IO.println(t[-1]) #> true
See also: at(index)