File tree 1 file changed +13
-0
lines changed
1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -1571,6 +1571,19 @@ for i in vec.iter() {
1571
1571
1572
1572
This code will print each number in order, on its own line.
1573
1573
1574
+ You can access a particular element of a vector, array, or slice by using
1575
+ ** subscript notation** :
1576
+
1577
+ ``` {rust}
1578
+ let names = ["Graydon", "Brian", "Niko"];
1579
+
1580
+ println!("The second name is: {}", names[1]);
1581
+ ```
1582
+
1583
+ These subscripts start at zero, like in most programming languages, so the
1584
+ first name is ` names[0] ` and the second name is ` names[1] ` . The above example
1585
+ prints ` The second name is Brian ` .
1586
+
1574
1587
There's a whole lot more to vectors, but that's enough to get started. We have
1575
1588
now learned all of the most basic Rust concepts. We're ready to start building
1576
1589
our guessing game, but we need to know how to do one last thing first: get
You can’t perform that action at this time.
0 commit comments