Types

Tuples

A tuple type is defined similarly to a tuple expression. For example, given two types a and b, the type (a, b) represents a tuple that consists of an element of type a and an element of type b. For example (felt, felt) may be used to represent a (2-dimensional) point.

Cairo also supports named tuples, for example (x : felt, y : felt) represents a tuple similar to (felt, felt) except that the two items are named x and y, respectively.

Used-defined type aliases

You can give a new alias for a type as follows:

using Point = (x : felt, y : felt)

Note that Point is not a new type in this case – it is only an alias to (x : felt, y : felt). You can use Point as an alias for this type.

For example, you may replace

local pt : (x : felt, y : felt) = (x=2, y=3)

with:

local pt : Point = (x=2, y=3)