klauern
1/25/2009 - 4:47 AM

Including a Ruby Library.rb

# Assume we have the following program and external_file.rb library with defined function external_function.


require "external_file.rb" 
a = external_function(1,2,3) 


# Where should the loaded library file be located if program executes without errors? Assume that the 
#   current directory is not the same as the disk root and executed program's directory.
# Note: No command line options were used to invoke Ruby

# Answers:
#   In one of the directories RUBYLIB environment variable points to if $SAFE=
#   In the current directory
# Explanation:
#   Ruby searches for the library files in the current directory and in RUBYLIB directories. This could 
#     be checked by looking at $: global variable contents.