From: "David A. Black" Date: 2004-02-26T02:58:00+09:00 Subject: Re: Operators +, += and = in Ruby 2 Hi -- On Thu, 26 Feb 2004, Robert Klemme wrote: > > Hi all, > > this occurred to me some days ago and I'd like to hear what others think. > > Operator += can't be user defined but instead is extended to a combination > of "+" and assignment: > "x += y" becomes implicitely "x = x + y". > > Now, wouldn't it be better to turn that around and have people define > operator += and automatically convert operator + like in: > > "x + y" becomes implicitely "x.dup += y" > > The reason I'm offering this is performance: "x = x + y" is slower than an > inplace manipulation (that += would do), which is often what's desired > here. But wouldn't calling dup be slower than not calling dup? x,y = "a", "b" z = x + y # vs. z = x.dup + y David -- David A. Black dblack@wobblini.net