summaryrefslogtreecommitdiff
path: root/Array notation.md
diff options
context:
space:
mode:
Diffstat (limited to 'Array notation.md')
-rw-r--r--Array notation.md13
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