No, because cb=null
only replace the referencing target of 'cb' from the original instance to null
, therefore c2
won't be affected.
When you just pass c2
into the function, the situation would be something like this:
cb c2
| |
------------------
| object |
------------------
once cb
is set to null
, it becomes
null--cb c2
|
-------------------
| object |
-------------------
and you return cb and assign to c3, it essentially does c3 = null
.
However, on the other hand, if you change the internal state of that object, then certainly the state of the object referred by all the references will be changed..