From: Robert Klemme Date: 2010-01-19T01:22:46+09:00 Subject: Re: basic question: passing a modifiable argument to a routine 2010/1/18 lalawawa > > 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? Apart from what Rick already said - the funny thing is: the fact that Ruby works this way (i.e. has a uniform object model as opposed to Java which does have non object types) makes a lot of things easier. And with the optimization Rick mentioned it even isn't too inefficient - something that Java programmer haunts when they use object types like java.lang.Integer and friends. I remember an article which elaborated on that design flaw of Java but I can't seem to find it right now. Maybe Charly has a link handy. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/