Skip to content

Commit 5999acd

Browse files
authored
feat: Add exercise variables6 covering const (#352)
1 parent 59f56b2 commit 5999acd

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

exercises/variables/variables6.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// variables5.rs
2+
// Make me compile! Execute the command `rustlings hint variables6` if you want a hint :)
3+
4+
// I AM NOT DONE
5+
6+
const NUMBER = 3;
7+
fn main() {
8+
println!("Number {}", NUMBER);
9+
}

info.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,21 @@ You can read more about 'Shadowing' in the book's section 'Variables and Mutabil
5656
https://doc.rust-lang.org/book/ch03-01-variables-and-mutability.html#shadowing
5757
Try to solve this exercise afterwards using this technique."""
5858

59+
[[exercises]]
60+
name = "variables6"
61+
path = "exercises/variables/variables6.rs"
62+
mode = "compile"
63+
hint = """
64+
We know about variables and mutability, but there is another important type of
65+
variable available; constants.
66+
Constants are always immutable and they are declared with keyword 'const' rather
67+
then keyword 'let'.
68+
Constants types must also always be annotated.
69+
70+
Read more about constants under 'Differences Between Variables and Constants' in the book's section 'Variables and Mutability':
71+
https://doc.rust-lang.org/book/ch03-01-variables-and-mutability.html
72+
"""
73+
5974
# IF
6075

6176
[[exercises]]

0 commit comments

Comments
 (0)