[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: ruby1.9 block scope

Yukihiro Matsumoto

9/29/2008 12:06:00 PM

Hi,

In message "Re: ruby1.9 block scope"
on Mon, 29 Sep 2008 19:54:43 +0900, Daniel DeLorme <dan-ml@dan42.com> writes:

|I could have sworn that one of the firm changes in ruby 1.9 was that
|variables defined inside a block would also exist outside the block. But
| when I try it:
|
| >> 1.times{ x=2 }
|=> 1
| >> x
|NameError: undefined local variable or method `x' for main:Object
|
|Did I dream all that? If it wasn't a dream, when and why was that change
|reversed?

I have once presented a plan to make it work so, but have never
implemented. So it's not "changed reversed". Just the idea
abandoned.

matz.

1 Answer

Daniel DeLorme

9/29/2008 12:24:00 PM

0

Yukihiro Matsumoto wrote:
> on Mon, 29 Sep 2008 19:54:43 +0900, Daniel DeLorme <dan-ml@dan42.com> writes:
>
> |I could have sworn that one of the firm changes in ruby 1.9 was that
> |variables defined inside a block would also exist outside the block. But
> | when I try it:
> |
> | >> 1.times{ x=2 }
> |=> 1
> | >> x
> |NameError: undefined local variable or method `x' for main:Object
> |
> |Did I dream all that? If it wasn't a dream, when and why was that change
> |reversed?
>
> I have once presented a plan to make it work so, but have never
> implemented. So it's not "changed reversed". Just the idea
> abandoned.

Ah, ok, then I guess I *did* dream the whole thing. For the record, I
think it's a great idea and deserves to be implemented... in ruby 2.0
maybe ;-)

--
Daniel