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
}
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
Post a Comment