Initial commit
This commit is contained in:
15
solutions/01_variables/variables3.rs
Normal file
15
solutions/01_variables/variables3.rs
Normal file
@@ -0,0 +1,15 @@
|
||||
#![allow(clippy::needless_late_init)]
|
||||
|
||||
fn main() {
|
||||
// Reading uninitialized variables isn't allowed in Rust!
|
||||
// Therefore, we need to assign a value first.
|
||||
let x: i32 = 42;
|
||||
|
||||
println!("Number {x}");
|
||||
|
||||
// It is possible to declare a variable and initialize it later.
|
||||
// But it can't be used before initialization.
|
||||
let y: i32;
|
||||
y = 42;
|
||||
println!("Number {y}");
|
||||
}
|
||||
Reference in New Issue
Block a user