That makes sense to me now.  I originally assumed that even though I was
calling the Proc inside of a block, that each block's parameter would be a
local variable (in it's own scope), and safe to pass along.

It looks like 1.9 clears that up by ensuring that any local variable in a
block is just that.  I tested Edward's example in Shoes & 1.8.7 (and the
second example gave me '3, 3, 3').  I test the same example under 1.9 and I
got '1, 2, 3'.

Putting the call inside of another function works as a hack, as it prevents
scope from any other 'url' variables I may have used in my code.  I'll keep
an eye on this in the future.

Thanks for all the help!

- scott

On Mon, Jul 27, 2009 at 8:11 AM, Jonas Elfström <[email protected]> wrote:

> On Mon, Jul 27, 2009 at 4:26 PM, Edward Heil<[email protected]> wrote:
> > Ruby's scoping rules with respect to iterators are kinda controversial
> even
> > by the standards of other languages with lexical scoping.  (In Lisp you'd
> be
> > able to look at the parentheses and know exactly what's in scope where!
> :)
> >  There's been talk of changing them but I'm not 1.9-savvy enough to know
> if
> > any of that has happened yet.
>
> It is changed. http://ruby.about.com/od/newinruby191/a/blockvariscope.htm
>
> --
> Jonas Elfström
>

Reply via email to