hello world and variables exploration

This commit is contained in:
Sil Klaasboer
2025-12-18 11:25:05 +01:00
parent 72cf887104
commit 54afcf45ee
6 changed files with 53 additions and 0 deletions

24
variables/src/main.rs Normal file
View File

@@ -0,0 +1,24 @@
//global variables use const or static NOT let and need a type indication
const NAME : &str = "John";
const HEX_NUM : &i32 = &0x01;
fn main() {
// local variables dont need a type indication and are by default immutable
let local_name = "Dough";
let normal_int = 35;
let hex_int = 0x35;
let bin_int = 0b10101111;
//make them mutable by mut modifier
let mut middle_name = "Levy";
println!("temp middle name: {}",middle_name);
middle_name = "Cena";
println!("name: {} {} {}",NAME,middle_name, local_name);
println!("age: {}", normal_int);
println!("hex: {}",hex_int);
println!("const hex: {}",HEX_NUM);
println!("binary: {}",bin_int);
}