POV-Ray : Newsgroups : povray.off-topic : Another "This is why I..." : Re: Another "This is why I..." Server Time
9 Oct 2024 02:30:17 EDT (-0400)
  Re: Another "This is why I..."  
From: Darren New
Date: 27 May 2009 14:39:41
Message: <4a1d88ed$1@news.povray.org>
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

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.