On Mon, Mar 27, 2006 at 04:23:54PM +0900, Robert Klemme wrote:
> Mohammad Khan wrote:
> >When I am writing
> >array.each do | blah | end
> >
> >It would be really convenient if blah is scopped only in this iterator
> >block, regardless of blah decleared before or not.
> 
> You wouldn't be able to do things like this:
> 
> sum = 0
> enum.each {|item| sum += item}

Not really; item being block-scoped wouldn't preclude access to other local
variables. What you wouldn't be able to do is:

def set_get
  a = nil
  [lambda{|a|}, lambda{a}]
end
set, get = set_get
set[1]
get[]                                              # => 1

forcing you to go this way:
  [lambda{|b| a = b}, lambda{a}]

-- 
Mauricio Fernandez  -   http://eigenclass.org   -  singular Ruby