Skip to content

Commit afc67da

Browse files
committed
update primitives.md with example of array and tuple
1 parent 8f94061 commit afc67da

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/primitives.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,15 @@ fn main() {
4949
5050
// Variables can be overwritten with shadowing.
5151
let mutable = true;
52+
53+
/* Compound types - Array and Tuples */
54+
55+
// Array signature consists of Type T and length as [T; length].
56+
let my_array: [i32; 5] = [1, 2, 3, 4, 5];
57+
58+
// Tuple is a collection of values of different types
59+
// and is constructed using parentheses ().
60+
let my_tuple = (5u32, 1u8, true, -5.04f32);
5261
}
5362
```
5463

0 commit comments

Comments
 (0)