Permalink
Browse files

docs: Explain underscore prefix in tutorial

  • Loading branch information...
1 parent 096bcd5 commit e3f458e6390d66b9634e7dce4aa7e91c091aebc6 @brson brson committed Oct 4, 2012
Showing with 7 additions and 2 deletions.
  1. +7 −2 doc/tutorial.md
View
@@ -240,8 +240,13 @@ let monster_size: int = 50;
~~~~
Local variables may shadow earlier declarations, as in the previous
-example in which `my_favorite_value` is first declared as a `float`
-then a second `my_favorite_value` is declared as an int.
+example in which `monster_size` is first declared as a `float`
+then a second `monster_size` is declared as an int. If you were to actually
+compile this example though, the compiler will see that the second
+`monster_size` is unused, assume that you have made a mistake, and issue
+a warning. For occasions where unused variables are intentional, their
+name may be prefixed with an underscore to silence the warning, like
+`let _monster_size = 50;`.
Rust identifiers follow the same rules as C; they start with an alphabetic
character or an underscore, and after that may contain any sequence of

0 comments on commit e3f458e

Please sign in to comment.