From: Rick DeNatale Date: 2010-01-19T00:47:55+09:00 Subject: Re: basic question: passing a modifiable argument to a routine On Mon, Jan 18, 2010 at 9:25 AM, lalawawa wrote: > When you say that += creates a different object, then are you saying > that when I do > > a = 0 > while a < 1000000 >  a += 1 > end > > it creates a million different objects and garbage collects most of > them?  Isn't that horribly inefficient for just doing integer > arithmetic? In this case, those integers are all Fixnums which are represented by immediate values, so no allocation or GC is involved. Of course if you are really concerned about efficiency you can always do that calculation as: a = (1000000*1000000 + 1000000) / 2 -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Twitter: http://twitter.com/RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale