On Wednesday 10 January 2007 16:04, Yukihiro Matsumoto wrote:
> I sometimes want to take out values from the block and I hate to be
> forced to assign only for "variable declaration", for example
> 
>   ary.each {|x|
>     if cond(x)
>       val = func(x)
>       break
>     end
>   }
>   p val   # val is out-of-scope
> 
> 							matz.

Well, out of my experience with other programming languages (and having 
experimented with building a compiler myself), I was always expecting that I 
have to declare a variable in the scope I want to use it in. I always would 
have prefixed your example with "val = nil" since that's how scoping works in 
almost all languages I know (with the lone exception of AWK ;-).

And I think it would be dangerous if val would leak into the outer scope of 
your example. Although I understand that it's inconvenient to be forced to 
declare val in the outer scope first :-)

Marc
-- 
Marc Haisenko
Comdasys AG

Resheimer Stra¡¬e 7
D-80686 Mchen
Tel: +49 (0)89 - 548 43 33 21
Fax: +49 (0)89 - 548 43 33 29
e-mail: haisenko / comdasys.com
http://www.comdasys.com