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

S

Stephan Kämper

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
 
N

nobu.nokada

Hi,

At Sun, 18 Jan 2004 02:45:03 +0900,
Stephan said:
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?
 
S

Stephan Kämper

What do you mean?

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,832
Latest member
GlennSmall

Latest Threads

Top