From: Alan Chen Date: 2002-09-14T02:41:54+09:00 Subject: Re: private variables On Fri, Sep 13, 2002 at 11:07:26PM +0900, Paul Brannan wrote: > On Thu, Sep 12, 2002 at 11:17:03PM +0900, Dave Thomas wrote: > > _a - localized block variable, > > > > _a = 1 > > > > 10.times {|_a| puts _a} > > > > puts _a # => 1 > > Interesting idea. > > Would non-localized block variables: > a) retain their original behavior (that is, they are local if the > variable already exists in the outer block, otherwise they are > non-local), or > b) always be non-local? > > I like (b) since it's cleaner, but (a) because it doesn't break any > code. > > On a side note, I wish there were another symbol that could be used in > place of _. It makes variables look asymmetric (unless you write _a_). > > Paul Wasn't there some talk about using symbols? It's not symmetric, but for some reason it looks better to me. a = 1 10.times { |:a| puts a } puts a # => 1 -- Alan Chen Digikata LLC http://digikata.com