Jump to content

Recommended Posts

You use references when you need to avoid the replication of variables.

 

Typically, when you pass a variable to a function, it is within the scope of that function only, and you must return the desired variable to get what you want your function to do.

 

When passing by reference, you are preserving the scope to that variable.  It's much like when you order something with Fedex.  When your package is received by Fedex, the don't go out and get a duplicate item to pass to the next branch.  They send YOUR package throughout all of the branches until it reaches your door.

 

If Fedex didn't "pass by reference", then your item would be received, put into a different box, perhaps even exchanged with a different yet similar item, and so on to each branch until it reached your door.  Hopefully that puts things into perspective.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.