Hello --

On Tue, 14 Aug 2001, Steven Brown wrote:

> I'm in the process of learning ruby and I've got a quick question for you
> guru folk..  Is there a way to make {|variable| ...} blocks such that the
> 'variable' is local to that block only?  Eg, so the following code would
> work instead of 'a' winding up 5:
>
> a = 9
> [1,3,5].each {|a| puts a}
> print "should be 9: ", a, "\n";

But if a doesn't wind up as 5, then the code didn't work :-)

There have been several threads about this: at the ruby-talk archives
(http://www.ruby-talk.com), do a search for "block local scope" and
you'll get most of the relevant posts.


David

-- 
David Alan Black
home: dblack / candle.superlink.net
work: blackdav / shu.edu
Web:  http://pirate.shu.edu/~blackdav