Assume x
is a gem, that contains both Hello
and Goodbye
classes.
If I write a program that require 'x'
, but only uses the Hello
class. Is the Goodbye
class loaded as well?
You include scripts or files, not gems.
With
require 'x'
you load the file x.rb
. Which x.rb
you load is defined by the search path, the search pathes can be modified by gem definitions (what you didn't use in your example code).
Everything inside the file x.rb
is loaded. If x.rb
contains other require
commands, those files are also loaded.
x
has Hello
& Goodbye
, using one of them will still load both since they're still in the same file - Andrew Marshall 2012-04-03 21:42