From: "David A. Black" Date: 2008-08-14T03:52:45+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-1394353213-1218653724=:17298 Content-Type: MULTIPART/MIXED; BOUNDARY="1926193751-1394353213-1218653724=:17298" 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-1394353213-1218653724=:17298 Content-Type: TEXT/PLAIN; charset=X-UNKNOWN; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE Hi -- On Thu, 14 Aug 2008, I=C3=B1aki Baz Castillo wrote: > El Martes, 12 de Agosto de 2008, David A. Black escribi=C3=B3: >> 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: >> >> =C2=A0 =C2=A0{|x,y,z;a| a =3D 1 } =C2=A0 =C2=A0# a is not bound to any b= lock args but is >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0# local to the block > > > Could I use that to avoid the problem if I do this: > > Thread.new(request) { |request| ... } > > This is a big problem since the "request" into the block points to the re= quest > outside, so each thread share it (dangerous). This is why I use: > > Thread.new(request) { |req| ... } > > Could I use this? > Thread.new(request) { |;request| ... } No, because you then have no block parameter to which to bind the thread object. Variables listed after the semi-colon are available as local variables in the block, but do not participate in the argument bindings. 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-1394353213-1218653724=:17298-- --1926193751-1394353213-1218653724=:17298--