Skip to content

Record

A record is a data structure that comprises a fixed number of fields. Each field has an identifier and an associated expression. In contrast with a tuple, where the names of the fields are implicitly assigned based on their order, a record allows users to define the names of its fields.

Constructor

workspace

Fig. 1: Record constructor

{bool = false, str = "is", num = 0}
/* Scala doesn't have primitive type of 'Record' */

workspace

Fig. 2: Binding a record constructor with a name

val record_constructor = {bool = false, str = "is", num = 0}
/* Scala doesn't have primitive type of 'Record' */

Projection

Projection is an operator that retrieves a specific field using its name.

workspace

Fig. 3: Record projection

(#str {bool = false, str = "is", num = 0})
/* Scala doesn't have primitive type of 'Record' */

workspace

Fig. 4: Application of record projection over a bound variable.

val record_constructor = {bool = false, str = "is", num = 0}
val projection = (#str record_constructor)
/* Scala doesn't have primitive type of 'Record' */