Skip to main content
Version: 1.6.0

Declaring

So far, we have seen relatively simple data types. LIGO also offers more complex built-in constructs, such as records.

Records are one-way data of different types can be packed into a single type. A record is made of a set of fields, which are made of a field name and a field type. Given a record, the value bound to a field is accessed by giving its name to the selection operator ".".

Let us first consider an example of record type declaration.

type user = {
id : nat,
is_admin : bool,
name : string
};

And here is how a record value is defined:

const alice : user = {
id : 1n,
is_admin : true,
name : "Alice"
};

Note: A semicolon ; can also separate fields instead of a comma.