it seems that we can load "some_file.rb" or require "some_file.rb" in irb to run the program. But after the run, i and a are both undefined. $g and foo on the other hand, are both defined. how can we make i and a both defined, just like we typed it in irb? i = 10 a = [1,2,3] $g = 100 def foo(i) puts i + 10000 end p i p a p $g p foo(i) irb(main):001:0> load "test_irb.rb" 10 [1, 2, 3] 100 10010 nil => true irb(main):002:0> $g => 100 irb(main):003:0> i NameError: undefined local variable or method `i' for main:Object from (irb):3 irb(main):004:0> a NameError: undefined local variable or method `a' for main:Object from (irb):4 irb(main):005:0> foo(123) 10123 => nil -- Posted via http://www.ruby-forum.com/.