From: Carlos Date: 2003-09-22T22:02:43+09:00 Subject: Re: Operator overloading > > > j += 1 > > > > > > is expanded before evaluation to: > > > > > > j = j + 1 > > > > Not quite - I think j += 1 only evaluates j once. I recall one instance > > where that helped me, performance-wise. > > The j on the left isn't being evaluated; it's just being assigned to. > So in cases with objects that can have more than one instance (like > String), you get a new object: He is referring to this case: def counter c=0 return proc { c+=1 } end cc = counter a = [ "a", "b", "c" ] a[cc.call] += "x" # only one cc.call evaluated, only a[1] changed a # [ "a", "bx", "c" ] cc = counter a = [ "a", "b", "c" ] a[cc.call] = a[cc.call] + "x" # a[1] = a[2] + "x" a # [ "a", "cx", "c" ]