Skip to content

Commit

Permalink
doc: update book 06_01_arrays (#195)
Browse files Browse the repository at this point in the history
  • Loading branch information
Atixx authored Dec 18, 2024
1 parent ab1eb5d commit 51cad6b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions book/src/06_ticket_management/01_arrays.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ let numbers: [u32; 3] = [1, 2, 3];
This creates an array of 3 integers, initialized with the values `1`, `2`, and `3`.\
The type of the array is `[u32; 3]`, which reads as "an array of `u32`s with a length of 3".

If all array elements are the same, you can use a shorter syntax to initialize it:

```rust
// [ <value> ; <number of elements> ]
let numbers: [u32; 3] = [1; 3];
```

`[1; 3]` creates an array of three elements, all equal to `1`.

### Accessing elements

You can access elements of an array using square brackets:
Expand Down

0 comments on commit 51cad6b

Please sign in to comment.