Compound datatypes
- Array
- Continuous group of items
- fixed length
- Length known at compile time
- homogeneous
Syntax:-
let array: [u32; 3] = [1,2,3];
let first_item = array[0];
let will_warn = array[100]; // compiler will warn while at runtime it will crash
- Tuples
- Linear group of items
- fixed length
- length known at compile time
- heterogenous
- Empty tuple is called unit
let tuple: (bool, u16, u8) = (true, 2, 3);
let first_item = tuple.0;
let error = tuple.100; // will give error