In which order are files looked for when loaded/requierd - and what's the order of suffixes?

Hi all,

when I

 require 'whatever'

or

 load 'something_else'

how can I tell in which order the directories are searched for the file
in question? And what’s the order fo suffixes to the file ( .rb, .so, …)?

Is the directory order the order of the entries in $: (or $LOAD_PATH
which I tend to prefer after requiring ‘English’)?
Hmm, probably not, since ‘.’ is the last entry in the current $: (which
I didn’t change)

Thanks for any input and happy rubying!

Stephan

···


"It’s POLYMORPHIC!!!"
A fromer colleague

Hi,

how can I tell in which order the directories are searched for the file
in question? And what’s the order fo suffixes to the file ( .rb, .so, …)?

Directories in $:, and suffixes are in order “rb”,
Config::CONFIG[“DLEXT”] and Config::CONFIG[“DLEXT2”] if
available. Config::CONFIG is defined in rbconfig.rb.

Is the directory order the order of the entries in $: (or $LOAD_PATH
which I tend to prefer after requiring ‘English’)?

Yes.

Hmm, probably not, since ‘.’ is the last entry in the current $: (which
I didn’t change)

What do you mean?

···

At Sun, 18 Jan 2004 02:45:03 +0900, Stephan Kämper wrote:


Nobu Nakada

Sorry for being unclear. I meant to say that

a) “.” is the last element of $:.

 [715] stk@tao ~: irb
 irb(main):001:0> $:
 => ["/usr/local/lib/ruby/site_ruby/1.8",
     "/usr/local/lib/ruby/site_ruby/1.8/i686-linux",
     "/usr/local/lib/ruby/site_ruby", "/usr/local/lib/ruby/1.8",
     "/usr/local/lib/ruby/1.8/i686-linux",
     "."]
 irb(main):002:0> $:.last == "."
 => true

b) I thought “.” would be searched first. Apparently I was wrong…

Thanks for your help!

Happy rubying everybody

Stephan

···

nobu.nokada@softhome.net wrote:

Hmm, probably not, since ‘.’ is the last entry in the current $: (which
I didn’t change)

What do you mean?


“It’s POLYMORPHIC!!!”
A fromer colleague