‹ Kinyanjui Wangonya

Tags / rust


By default, variables are immutable in Rust. Coming from a Python background, I have to keep in mind that this:

fn main() {
    let var = 10;
    println!("var = {}", var);  // var = 10
    var = 5;  // try and reassign var
    println!("var is now {}", var);
}

… will not compile.

« Older posts Newer posts »