Tuples

A tuple is an essential data type in Leaf. These are simple structures which contain an ordered list of other types. The fields can be anonymous, or named.

//tuple of 3 numbers
var a = [ 1, 2, 3 ] 
trace( a#1 )

//nested tuples
var b = [ a, [ 8 ] ]
//prints '3' (the first subscript returns the value of 'a', and the second one the part of 'a')
trace( b#0#2 )

//named fields
var c = [ 
    one = 1,
    two = 2,
] 
trace( c.one )

The simple syntax of tuples is made possible by type inferencing and conversion. All of the values above have concrete static types, but you don't have to write them. Consider how troublesome it'd be to declare the static type of b!