|
|
Warp wrote:
> Darren New <dne### [at] sanrrcom> wrote:
>>>> My point is that if you do
>>>> a = 5; b = a; a = 7;
>>>> you're not changing the value in b.
>>> Of course you are. You are changing it to 5.
>
>> Right. You're not changing the value in b when you assign 7 to a.
>
> Uh? That's because you are changing the value of a, not the value of b.
Yes! Precisely. You're not changing the value of 5. You're changing the
value of 'a'.
Contrast with
a = " hello "; b = a; a.trim();
Whether you changed 'b' depends on whether string literals have value or
reference semantics. *Unless* strings are read-only, in which case a.trim()
returns a new string which gets discarded.
--
Darren New, San Diego CA, USA (PST)
There's no CD like OCD, there's no CD I knoooow!
Post a reply to this message
|
|