From: MenTaLguY Date: 2008-08-14T03:46:16+09:00 Subject: Re: Ruby 1.9: What to Expect by Sam Ruby @ OSCON 2008 Slide Deck Adapted S6/S9 (Single-Web Page) Version --=-JBWboZtVqKASBgrQGwBI Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Thu, 2008-08-14 at 03:33 +0900, I=C3=B1aki Baz Castillo wrote: > Could I use that to avoid the problem if I do this: >=20 > Thread.new(request) { |request| ... } >=20 > This is a big problem since the "request" into the block points to the re= quest=20 > outside, so each thread share it (dangerous). This is why I use: >=20 > Thread.new(request) { |req| ... } >=20 > Could I use this? > Thread.new(request) { |;request| ... } In 1.9, you don't need to. Block parameters shadow local variables, such that this works fine: Thread.new(request) { |request| ... } In 1.9, 'request' inside and outside the block are different variables. (I'm still not entirely sure I'd recommend calling them the same thing, for readability's sake, but you can do it now...) -mental --=-JBWboZtVqKASBgrQGwBI Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQBIoyxwEpMFVe94r24RAki0AJ43oKx8J6oW+dApUxc17mTiNDCM4gCfYsrh LvdoHbULEcJZTCSDMGmeY1k= =ll6l -----END PGP SIGNATURE----- --=-JBWboZtVqKASBgrQGwBI--