Hi --

On Fri, 13 Dec 2002, [ISO-8859-1] MaurùÄio wrote:

>    Guys,
>
>    When we use
>
> require 'some_code'.
>
> where (i.e., in which directories) does require looks for 'some_code'?

Short answer: those listed in the global variable $:

Longer answer:

candle:~$ ri require
-------------------------------------------------------- Kernel::require
     require( aString ) -> true or false
------------------------------------------------------------------------
     Ruby tries to load the library named aString, returning true if
     successful. If the filename does not resolve to an absolute path,
     it will be searched for in the directories listed in $:. If the
     file has the extension ``.rb'', it is loaded as a source file; if
     the extension is ``.so'', ``.o'', or ``.dll'',[Or whatever the
     default shared library extension is on the current platform.] Ruby
     loads the shared library as a Ruby extension. Otherwise, Ruby tries
     adding ``.rb'', ``.so'', and so on to the name. The name of the
     loaded feature is added to the array in $". A feature will not be
     loaded if it already appears in $". require returns true if the
     feature was successfully loaded.
        require "my-library.rb"
        require "db-driver"


David

-- 
David Alan Black
home: dblack / candle.superlink.net
work: blackdav / shu.edu
Web:  http://pirate.shu.edu/~blackdav