Until now, the only data types we have worked with are the integer and floating-point number types and the Bool type (for true and false). Let's broaden our repertoire.
The aggregate types are used to define multi-valued data structures having one of these forms:
- Array types. These hold several values (elements) that are all the same type. An array's elements are co-located in memory and can be individually accessed using an integer index.
- Struct types. These hold one or more co-located values (fields), each of which might have a different type. A field value can be individually accessed using its declared name.
- Enum and Union types. Enums hold a single value whose type could be one of several possible variations. Unions hold multiple values, with variations on how some of the data is structured. The value's "tag" can be examined to determine which variation is currently in use.
The next few pages describe how to declare a named, custom aggregate type having one of these forms, construct an aggregate value, and work with the value(s) that lie within.