From: matz@... (Yukihiro Matsumoto) Date: 2001-04-10T00:30:38+09:00 Subject: [ruby-talk:13580] Re: about the the scope of a local variable Hi, In message "[ruby-talk:13577] Re: about the the scope of a local variable" on 01/04/09, ts writes: |>>>>> "R" == Richard P Groenewegen writes: | |R> not so: if I put `a = 1' before the require line, the value of a stays |R> 1. Is there any way to access the `a' in atest.rb? | | Try this : | | +----------------+ +--------------------+ | | file: atest.rb | | file: btest.rb | | +----------------+ +--------------------+ | | puts a | | a = 12 | | a = 24 | | require 'atest.rb' | | | puts a | | puts a | | +----------------+ +--------------------+ Yes, but this behavior will be changed in the future. require/load will not copy the toplevel local variables, so that the first reference to a in atest.rb will raise an exception. matz.