From: Yuh-Ruey Chen Date: 2008-11-01T04:38:58+09:00 Subject: Re: How to access to local variables in enclosing scopes? On Oct 31, 2:18 pm, Stefan Lang wrote: > Since it's a bad idea anyway to reassign such variables > (metaprogramming might be an exception), you can use > Ruby's constants for this purpose: > >     module MyModule > >         A = 20 > >         # can access A from anywhere within MyModule, >         # including method definitions, nested classes, etc. > >     end > >     puts MyModule::A  # access from outside of MyModule Oops, forgot to reply to this bit. This is not what I'm really looking for. I don't care about accessing variables within another unrelated scope - in fact, unless explicitly allowed, it should not be allowed. I only care about accessing variables in enclosing scopes.