From: Jeremy Kemper Date: 2008-08-13T06:09:06+09:00 Subject: Re: Ruby 1.9: What to Expect by Sam Ruby @ OSCON 2008 Slide Deck Adapted S6/S9 (Single-Web Page) Version 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