You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
let (course,category) =("Rust","beginner"); assigning multiple variables.
Scope
Scope of variable is inside the {} of it being declared.
Shadowing
Variable shadowing is a technique in which a variable declared within a certain scope has the same name as a variable declared in an outer scope. This is also known as masking.
fnmain(){let a = 123;let b = {let b = 89;println!("{} -> {}", a, b);
b
};println!("{} -> {}", a, b);}// 123 -> 89// 123 -> 89
Declaring constants & static
One can create a global constant at any level from Mod Level till function level
when we try to modify static variable and try to re-assign value, we need to put under unsafe block