On Tue, Mar 25, 2008 at 1:49 PM, Robert Klemme <shortcutter / googlemail.com> wrote: > 2008/3/25, Jesù¸ Gabriel y GaláÏ <jgabrielygalan / gmail.com>: > > On Tue, Mar 25, 2008 at 11:23 AM, Robert Klemme > > <shortcutter / googlemail.com> wrote: > No, this has nothing to do with immediate values. The reason why this > works is that an operation is used that creates a new instance > (Fixnum#+ in this case) and uses assignment to place a new value on > every iteration. This also works with arrays and other non immediate > and even mutable instances: > > irb(main):001:0> collector = Hash.new [] > => {} > irb(main):002:0> 10.times {|i| collector[i%3] += [i]} > => 10 Ah, ok, now I see what you mean. I didn't consider this case, because you are creating intermediate arrays every iteration. In my head I was equating the += for Fixnums with << for Arrays in this idiom, if you see what I mean. Thanks, Jesus.