update variables with type indication and added data types

This commit is contained in:
Sil Klaasboer
2025-12-18 11:34:22 +01:00
parent 54afcf45ee
commit 1529443824

View File

@@ -2,14 +2,15 @@
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;
let local_name: &str = "Dough"; // must be surrounded by double quotes
let normal_int: i32 = 35;
let hex_int: i32 = 0x35;
let bin_int: i32 = 0b10101111;
let height: f64 = 1.79;
let character: char = 'M';
let has_driver_license: bool = true;
//make them mutable by mut modifier
let mut middle_name = "Levy";
@@ -18,6 +19,9 @@ fn main() {
println!("name: {} {} {}",NAME,middle_name, local_name);
println!("age: {}", normal_int);
println!("gender: {}",character);
println!("has driver license: {}",has_driver_license);
println!("height: {}",height);
println!("hex: {}",hex_int);
println!("const hex: {}",HEX_NUM);
println!("binary: {}",bin_int);