Hi,

Am Montag, 07. Dez 2009, 14:09:53 +0900 schrieb Donghui Ouyang:
> I have two source files in the same directory: a.rb and b.rb
> 
> ---- a.rb ----
> puts "Hello form a.rb"
> 
> ---- b.rb ----
> load 'a'
> puts "Hello from b.rb"
> load 'a'
> puts 'Hello again from b.rb'
> 
> When I run the b.rb, It cause a LoadError: no such file to load
> But if I replace 'a' with 'a.rb' in b.rb, the program run successfully.

The most has been said already.

  - "require" loads once, "load" everytime.
  - only "require" will try to add ".rb", ".so", etc.
  - both "require" and "load" will search the "$:" path.

"$:" is equivalent to "$LOAD_PATH".

Bertram


-- 
Bertram Scharpf
Stuttgart, Deutschland/Germany
-
Discover String#notempty? at <http://raa.ruby-lang.org/project/step>.