Valentin, thank you for the correction and the detailed articles!
The mental model I've had that "primitives are passed by value; objects are passed by reference" has served me well over the years, and it's been helpful in understanding what behavior to expect, but it appears that I've been using the incorrect terms to explain what's really going on underneath the hood.
I've read through all your linked references. Just for my understanding, it seems like the following statement from the Stack Overflow answer is an appropriate way to explain the concept, right?
Primitives are passed by value. Objects are passed by "copy of a reference".
Or as you've said:
It is always pass by value. The "value" of an object is the reference.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Valentin, thank you for the correction and the detailed articles!
The mental model I've had that "primitives are passed by value; objects are passed by reference" has served me well over the years, and it's been helpful in understanding what behavior to expect, but it appears that I've been using the incorrect terms to explain what's really going on underneath the hood.
I've read through all your linked references. Just for my understanding, it seems like the following statement from the Stack Overflow answer is an appropriate way to explain the concept, right?
Or as you've said: