From: Dave Thomas Date: 2001-03-13T15:01:41+09:00 Subject: [ruby-talk:12548] Re: FEATURE REQUEST: 'my' local variables ts writes: > >>>>> "D" == Dave Thomas writes: > > D> n = 123 > D> 3.times {{ > D> puts n > D> n += 2 > D> }} > > What do you expect with > > a = [1] > 3.times {{ > a << 2 > }} > p a [1,2,2,2], the same as if you passed 'a' in to a method def x(a) a << 2 end a = [1] x a x a x a p a #=> [1,2,2,2] If you wanted to avoid object aliasing, you could eliminate the convenience that variables in a block are initialized to their outer-scope counterparts, and instead force people to pass them in as parameters to the block. However, I'd say that the Ruby way would favor convenience over such purity :) Regards Dave