Total newby here, when would I want to reassign a variable rather than finding where I first put it in and changing it there?
well, what if the variable contains user input? You can’t change what the users enter into your program. Or data from a database, there are plenty of situation where re-assigning is preferable.
you will see the re-assign is very common practice, its certainly has its value
I think you might be mixing up variables and values o.o
variables hold references to values, so that you can use those values again later
And you’d reassign a variable to update its value, perhaps you want to increase it by 1 - you’d do that by computing a new value and assigning the variable to that instead
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.