File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 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() {
15711571
15721572This code will print each number in order, on its own line.
15731573
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+
15741587There's a whole lot more to vectors, but that's enough to get started. We have
15751588now learned all of the most basic Rust concepts. We're ready to start building
15761589our 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