Rust - Scope

 Scope:


scope of a variable starts where it's defined and ends at the bloc's end.


always local to scope


fn main(){

let x = 5;

{

    let x = 6;

    println!({},x);//x value 6

}

println!("{}",x); //x value is 5

}

Comments

Popular posts from this blog

BIOFLOC