--0016e68e8acd5a1fa7047a1d17cd
Content-Type: text/plain; charset=ISO-8859-1

Evening Donghui,

On Sun, Dec 6, 2009 at 9:09 PM, Donghui Ouyang <exper.alpha / gmail.com>wrote:

> Hello All
>
> I have two source files in the same directory: a.rb and b.rb
>
> The content of a.rb is as follow:
>
> puts "Hello form a.rb"
>
> and b.rb is
>
> 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.
> It really confuse me.
>
>
I assume your confusion is why when you use require the .rb is not needed
while for loaded it is. Require is for pulling in libraries and thus the
parameter to require is the library name which ruby then takes and attempts
to find by adding .rb, or a library extension (.so on linux, .dll on windows
and such). Load on the other hand is specifically for the loading of files
and therefore a full filename is needed to be passed.

You'll also find that while require will only load a library once - the load
command will load a file as many times as it is called.

Hope things help clear things up

John

--0016e68e8acd5a1fa7047a1d17cd--