Record is a composite data type that groups named fields into a single value.
A record is similar to a struct. The term “record” is often used in languages and type systems where the focus is on named fields rather than memory layout.
For example, in Typescript:
type User = {
name: string
age: number
}Records are useful for:
- Modeling structured data
- Describing API payloads
- Grouping related values
- Giving names to fields
In some languages, records are immutable by default. In others, record-like values may be mutable objects.
Anki
id: record-definition deck: Computer Science::Data Types tags: data-types record
Q: What is a record? A: A record is a composite data type that groups named fields into a single value.
id: record-vs-struct deck: Computer Science::Data Types tags: data-types record struct
Q: How is a record related to a struct? A: A record is similar to a struct, but the term often emphasizes named fields rather than memory layout.