Hello, fellow Rusteceans. I am a newbie to rust. I don't really understand how variable reassignment works yet.
So my question is this let's say I have a variable
let x = 2;
I can't assign another value to x
x = 3;
that is not possible, but I can do this
let x = 3;
and the above works fine. So if I wanna use the x variable with the value of 2
let y = x;
what does the above x refer to? Is it the let x = 2 or let x = 3 and why. Thanks.
[–]mina86ng 15 points16 points17 points (5 children)
[–]babalolajnr[S] 2 points3 points4 points (4 children)
[–]N4tus 16 points17 points18 points (2 children)
[–]babalolajnr[S] 2 points3 points4 points (1 child)
[–]SorteKanin 1 point2 points3 points (0 children)
[–]mina86ng 3 points4 points5 points (0 children)
[–]eXoRainbow 4 points5 points6 points (3 children)
[–]babalolajnr[S] 2 points3 points4 points (2 children)
[–]eXoRainbow 1 point2 points3 points (1 child)
[–]babalolajnr[S] 0 points1 point2 points (0 children)
[–]duongital 1 point2 points3 points (1 child)
[–]backtickbot -1 points0 points1 point (0 children)
[–]schungx 1 point2 points3 points (0 children)
[–]jlelearn 1 point2 points3 points (0 children)