From: "Iñaki Baz Castillo" Date: 2008-08-13T06:25:42+09:00 Subject: Re: Ruby 1.9: What to Expect by Sam Ruby @ OSCON 2008 Slide Deck Adapted S6/S9 (Single-Web Page) Version El Martes, 12 de Agosto de 2008, Jeremy Kemper escribió: > On Tue, Aug 12, 2008 at 1:36 PM, Iñaki Baz Castillo wrote: > > El Martes, 12 de Agosto de 2008, Gerald Bauer escribió: > >> * Block Variables Now Shadow Local Variables > > > > What does it mean? For example, in Ruby 1.8 and 1.9 the following code > > returns the same: > > > > ---------- > > kk=123; > > puts "KK out of block = #{kk}"; > > 1.upto(3) { puts "KK in block = #{kk}"; kk=999 }; > > puts "KK out of block = #{kk}" > > ---------- > > > > KK out of block = 123 > > KK in block = 123 > > KK in block = 999 > > KK in block = 999 > > KK out of block = 999 > > $ irb-1.8 > > >> a = 1 > > => 1 > > >> [2].each { |a| } > > => [2] > > >> a > > => 2 > > $ irb-1.9 > > >> a = 1 > > => 1 > > >> [2].each { |a| } > > => [2] > > >> a > > => 1 > > So the block arg 'a' no longer clobbers the local var 'a'. > > jeremy No sure if I understand you. Please lok at this code: ~# irb1.8 irb(main):001:0> a=1 1 irb(main):002:0> [2].each { a=3 } [2] irb(main):003:0> a 3 ~$ irb1.9 irb(main):001:0> a=1 1 irb(main):002:0> [2].each { a=3 } [2] irb(main):003:0> a 3 the result is the same (but true, if I run your code in 1.8 and 1.9 result is different, but I don't understand which is the difference between your code and mine). -- Iñaki Baz Castillo