diff options
author | Jasper Ras <jras@hostnet.nl> | 2025-08-03 22:29:47 +0200 |
---|---|---|
committer | Jasper Ras <jras@hostnet.nl> | 2025-08-03 22:29:47 +0200 |
commit | 931eb0894e7cd3717f1218f0eb06382b11734c13 (patch) | |
tree | b6ad9b0d98a8f26e496c91ad3f24d1c855b654df /Array notation.md | |
parent | af98004d2cf437603f47f4224110a80d76d0d7de (diff) |
vault backup: 2025-08-03 22:29:47
Diffstat (limited to 'Array notation.md')
-rw-r--r-- | Array notation.md | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Array notation.md b/Array notation.md new file mode 100644 index 0000000..b4cc810 --- /dev/null +++ b/Array notation.md @@ -0,0 +1,13 @@ +[[Rust]] + +The array notation is a bit special compared to other languages so I will write it down here: + +Unlike tuples, arrays can only hold one type: + +`let a: [i32; 5] = [1, 2, 3, 4, 5]` Specifies an array of length 5. +`let a = [3; 5];` specifies an array of length 5 with all values set to 3. +> Note the semicolon rather than a comma! + +Indexing as usual + +Out of bounds access result in a panic.
\ No newline at end of file |