File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change 1+ // variables5.rs
2+ // Make me compile! Execute the command `rustlings hint variables5` if you want a hint :)
3+
4+ // I AM NOT DONE
5+
6+ fn main ( ) {
7+ let number = "3" ;
8+ println ! ( "Number {}" , number) ;
9+ number = 3 ;
10+ println ! ( "Number {}" , number) ;
11+ }
Original file line number Diff line number Diff line change @@ -41,6 +41,20 @@ value. We can't print out something that isn't there; try giving x a value!
4141This is an error that can cause bugs that's very easy to make in any
4242programming language -- thankfully the Rust compiler has caught this for us!"""
4343
44+ [[exercises ]]
45+ name = " variables5"
46+ path = " exercises/variables/variables5.rs"
47+ mode = " compile"
48+ hint = """
49+ In variables3 we already learned how to make an immutable variable mutable
50+ using a special keyword. Unfortunately this doesn't help us much in this exercise
51+ because we want to assign a different typed value to an existing variable. Sometimes
52+ you may also like to reuse existing variable names because you are just converting
53+ values to different types like in this exercise.
54+ Fortunately Rust has a powerful solution to this problem: 'Shadowing'!
55+ You can read more about 'Shadowing' in the book's section 'Variables and Mutability'.
56+ Try to solve this exercise afterwards using this technique."""
57+
4458# IF
4559
4660[[exercises ]]
You can’t perform that action at this time.
0 commit comments