From: "David A. Black" Date: 2008-08-13T06:33:14+09:00 Subject: Re: Ruby 1.9: What to Expect by Sam Ruby @ OSCON 2008 Slide Deck Adapted S6/S9 (Single-Web Page) Version --1926193751-107304090-1218576946=:27956 Content-Type: MULTIPART/MIXED; BOUNDARY="1926193751-107304090-1218576946=:27956" This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --1926193751-107304090-1218576946=:27956 Content-Type: TEXT/PLAIN; charset=X-UNKNOWN; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE Hi -- On Wed, 13 Aug 2008, I=F1aki Baz Castillo wrote: > El Martes, 12 de Agosto de 2008, I=F1aki Baz Castillo escribi=F3: > >> the result is the same (but true, if I run your code in 1.8 and 1.9 resu= lt >> is different, but I don't understand which is the difference between you= r >> code and mine). > > Maybe the difference occurs when the variable is passed to the block as > parameter ( {|a| ..} ) ? Yes. If it's a block parameter, it will not clobber the outer variable. If you just use a variable (non-parameter) in the block, then it is the same as the outer variable. (That's how blocks work as closures.) If you want to use a non-parameter inside a block and have it not clobber an outside variable, you can declare it as a local variable by putting it after a semi-colon in the parameter list: {|x,y,z;a| a =3D 1 } # a is not bound to any block args but is # local to the block David --=20 Rails training from David A. Black and Ruby Power and Light: * Advancing With Rails August 18-21 Edison, NJ * Co-taught by D.A. Black and Erik Kastner See http://www.rubypal.com for details and updates! --1926193751-107304090-1218576946=:27956-- --1926193751-107304090-1218576946=:27956--