From: Leo Razoumov Date: 2001-03-16T14:40:03+09:00 Subject: [ruby-talk:12711] Re: Order, chaos, and change requests :) >>>>> "YM" == Yukihiro Matsumoto writes: YM> Hi, YM> In message "[ruby-talk:12615] Re: Order, chaos, and change requests :)" YM> on 01/03/14, Leo Razoumov writes: YM> |n = 0 YM> |my = 1 YM> |(1..100).each \ YM> |{ YM> | YM> | |n| YM> | my += n YM> | # .... YM> |} YM> |n # -> 10 #side effect, 'n' was overriden within the block YM> |my # -> 1 #still old value, not affected by block-local var. of the same name YM> I like this except that I feel name duplication like the following is YM> little bit messy. YM> array.each {|i|...} YM> matz. I think this is not a duplication of names because the semantics and meaning of two constructs are different. For example, n = 0 i = 0 array.each { |n| ...} # 'n' is being overridden by 'yield' (called by each) # while 'i' is shadowed. array.each { |i| ...} # 'i' is shadowed so that even "yield" does not affect it. -- Leo [ slonika AT yahoo DOT com ]