From: Suraj Kurapati Date: 2008-10-02T05:29:23+09:00 Subject: Re: ruby1.9 block scope Brian Candler wrote: > def my_find(a) > # res=nil not needed! > a.each { |e| res = e if e =~ /foo/ } > res > end IMHO, the res=nil is necessary to preserve the semantics of a closure: A lambda/closure should *enclose* the variables around it into a neat package. It should *not* emit new variables into its surroundings! Otherwise, it would be something like an "opener" instead of a "closure". > I still think the current rule ("tmp is part of the closure if it is > assigned to earlier in the method") is much more sane than the suggested > alternative ("tmp is part of the closure if it is assigned to earlier > *or later* in the method") I agree wholeheartedly and I hope Ruby does not change in this regard. -- Posted via http://www.ruby-forum.com/.