From: William Djaja Tjokroaminata Date: 2002-10-22T22:16:50+09:00 Subject: Re: Things That Newcomers to Ruby Should Know (10/16/02) Hi Ian, Based on previous responses, I think a standard example answer to your question is something like this: a = 'aString' c = a a += ' modified using = +' puts c # -> "aString" a = 'aString' c = a a << ' modified using <<' puts c # -> "aString modified using <<" Because in Ruby the "=" operator only copies the reference (but not the object), based on the above example, probably you can tell which is more natural: for the "a += b" to behave like "a = a + b" or to behave like "a << b". If you know C++, then you know that Ruby has made a particular choice: Ruby does not overload the assignment operator and Ruby does not treat the "+=" operator as independent from the corresponding "=" operator. Although there are always exceptions, I think so far Ruby's philosophy in this regard is the most natural. Furthermore, Ruby still gives you a choice for a String as in the example above. If your intention is to create a new object (as not to affect c), you want to use "+="; if your intention is really to modify the object referred to by a, you want to use "<<" (but be careful that other variables such as c are also affected). Regards, Bill ========================================================================== Ian Macdonald wrote: > I understand that, but since 'a' already exists prior to assigning a + b > to it, why does it need to be recreated? Where strings are concerned, > I don't see why this would be any different to 'a << b'.