ExpandCollapsePrev Next Index

+ 13.1 Tuples

We can combine several values in a comma separated list to form tuple.


The type of this value is:

    int * double * string

The {*} symbol here means multiply. The type of a tuple is sometimes called the Cartesian Product (after Descartes). You can retrive a value from a tuple with a integral literal:

    val x = 1,2.9,"Hello";
    println x.0; // 1
    println x.1; // 2.9
    println x.2; // "Hello"


Note the field numbers are zero origin in keeping with C conventions. There are no tuples with one component.

+ 13.1.1 Unit

However, there is a tuple with no components with a single unique value:


the type of which is called unit type and can also be designated by 1.