From: William James Date: 2005-07-30T15:41:01+09:00 Subject: Re: make local var visible Pe�a, Botp wrote: > yes, sir Matz. I've already also tried that and I like class vars. But how > can I answer my peer's question, "duh, and your telling us to change our > sh/perl scripts to that? I thought you said ruby is easy to our eyes and > brain, botp?" ? > > my humble request is: can we not extend "locals" to embrace scope outside so > they may act like class vars? > > something like this i want if possible, > > # script.rb > #--------------------- > classvar x # maybe, we may declare x as a class local var (just my term) > # as if x now has nature like @@x > > x=1 > def mx1 > p x #-> 1 > end > p x #-> 1 > > def mx2 > x = 2 # same x updated > p x #-> 2 > end > p x #-> 2 > > It is really @@x but without the @@. > I hope i am not asking too much :( You say that you are converting Perl code, which is usually full of $'s and @'s, so this probably looks no worse than what you would have converted it from: $x=1 def mx1 p $x end mx1 p $x def mx2 $x = 2 p $x end mx2 p $x