From: Harry Ohlsen Date: 2003-11-17T08:05:22+09:00 Subject: Re: Local Variable Scope in Ruby2 Michael Neumann wrote: >>a = nil >> >>some_collection.each do |x| >> if some_condition >> a = ... >> break >> end >>end > > > This will work exactly the same way as in Ruby 1.8. The assignment > inside the block will assign to the outer variable (a). Any assignment > inside a block with the exception of assignements to block parameter > variables (here x), will be to variables outside the block. Ah! Thanks Michael. I completely misread Matz's slide. > In Rite you won't need a "a = nil" line anymore. "a=" inside the block > will automatically introduce a variable "a" outside the block. This is much nicer. I'm more likely to get it right first time, now :-). Cheers, Harry O.