Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions 09_features_compared/types.md
Original file line number Diff line number Diff line change
Expand Up @@ -364,8 +364,8 @@ Rust has a less powerful syntax than is possible with initialized arrays in C++
// Stack
let values = [0f64; 100]; // 100 elements initialised to 0
let values = [1f64, 2f64, 3f64]; // 3 elements 1,2,3
// Heap
let values = Box::new([0f64; 100]);
// For heap allocated arrays you should use vectors
let values = Box::new([0f64; 100]); // Allocates on heap with allocating on stack first. Try increasing number of elements to see stack overflow.
```

Note how Rust provides a shorthand to initialise the array with the same value or assigns the array with every value. Initialisation in C and C++ is optional but it is more expressive in that portions of the array can be set or not set using enclosed list syntax.
Expand Down