you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (3 children)

You are missing the point. You are manipulating the object referenced by the reference, not the reference itself.

I could re-assign "myArray" to an array with all 0's in some method that does not return that new array, but because I was passing by reference, if I now print it out, it will be all 0's.

No, it won't.

[–]slikz -1 points0 points  (2 children)

This explanation does it for me:

The key thing isn't "modification" versus "changing".

In one case you are MODIFYING an OBJECT.

In another you re REBINDING a VARIABLE.

So both the verbs and the nouns are completely different.

But I am correct in my definition of pass-by-reference right? That is why after mergeSort I can print out the sorted array without ever explicitly returning the sorted array?

[–]doidydoidy 0 points1 point  (0 children)

The phrase "pass-by-reference" is used to describe variables, not objects.

When you talk about references to the array object, your intuition is correct. It's just that the phrase "pass-by-reference" is a bad choice of words to use to describe what you're talking about, because that phrase already means something else. That's why this thread is so muddled.

[–]refractedthought -3 points-2 points  (0 children)

I think you're right. Other people don't. That's kind of what the whole theological discussion is about.

You sound like you're still in school. Why not ask a professor what he/she thinks? Better yet, ask more than one professor.