Raspberry Pi, Rust, Scheme Lisp, Android, Python, C++, JavaScript, Git, even Java. So long as it’s programming, I’m happy.

  • 10 Posts
  • 3 Comments
Joined 4 years ago
cake
Cake day: December 9th, 2020

help-circle
  • @maegul@lemmy.ml Yeah if you wanted to modify the original variable you would need to make it mutable, and use &mut references to it all the way down. By changing the function parameter to be mutable, we’re not modifying anything outside of this function: we’re just allowing ourselves to re-use the parameter to hold different values while the function is running. I don’t particularly like doing that - I’d prefer to make a new local variable if I want to change things within the function, but I think the exercise might have said I wasn’t allowed to make new variables :-)