Joel VanderWerf
3/5/2008 11:07:00 PM
Damjan Rems wrote:
> I am just wondering is there any differnece between these two
> techniques.
#load uses the $LOAD_PATH, just as #require does:
irb(main):001:0> load "fileutils.rb"
=> true
irb(main):002:0> FileUtils
=> FileUtils
However, #load doesn't check if something is already loaded:
irb(main):003:0> load "fileutils.rb"
/usr/local/lib/ruby/1.8/fileutils.rb:93: warning: already initialized
constant OPT_TABLE
/usr/local/lib/ruby/1.8/fileutils.rb:1163: warning: already initialized
constant S_IF_DOOR
/usr/local/lib/ruby/1.8/fileutils.rb:1513: warning: already initialized
constant METHODS
=> true
$ qri load
------------------------------------------------------------ Kernel#load
load(filename, wrap=false) => true
------------------------------------------------------------------------
Loads and executes the Ruby program in the file _filename_. If the
filename does not resolve to an absolute path, the file is searched
for in the library directories listed in +$:+. If the optional
_wrap_ parameter is +true+, the loaded script will be executed
under an anonymous module, protecting the calling program's global
namespace. In no circumstance will any local variables in the
loaded file be propagated to the loading environment.
--
vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407