[LRUG] Unexpected behaviour of << operator

Marcus Roberts marcus at marcusr.org.uk
Wed Aug 18 08:33:32 PDT 2010


On 18 Aug 2010, at 16:19, Damian Janowski wrote:

> On Wed, Aug 18, 2010 at 12:15 PM, Marcus Roberts <marcus at marcusr.org.uk> wrote:
>> I've just been chasing down a weird bug, the cause of which was accidentally using << instead of =
> 
> 
> 
> In the second case, you're concatenating to the string object to which
> both n and p.name are pointing. Thus it's modified 'everywhere'.
> 

Actually, giving it more thought, of course that makes sense, and it is indeed what I would expect - too much treating a string like a string and not an object!

Marcus




More information about the Chat mailing list