Levi Neuxell wrote:While browsing the topics I found the same swap style used here as well: Tony Marchant's post [Save for parameters]
fred rosenberger wrote:He doesn't have to tell me he is done, or tell me what color my bedroom is.
fred rosenberger wrote:Think of a variable as holding an address, similar to a rolodex card. I have a card with my home address on it. In my house, my bedroom is blue.
Now, I can pass a copy of the card to a painter. I give him a COPY of my home address. He can then go to my house, and paint the room white. He doesn't have to tell me he is done, or tell me what color my bedroom is.
But the next time I go and look at my bedroom, it will be white.
These methods work the same way. The calling method (correlates to me) has the address (on a rolodex card) of the object (my house). it passes a copy of the address to the sub-method (the painter). The sub method then does its thing (paints the room). It then throws away its copy of the address. The calling method the looks at the object, and see the changes.