On Tue, 12 Aug 2003, Dinesh Nadarajah wrote:

> I am new to the language so please excuse me for this simple question.
> What is the different between include and require statements?

require() is like load() except it does it only once per file. load() is
like eval() except it works on a file instead of a string. eval() executes
a string as a ruby program.

include() is Ruby's multiple inheritance mechanism, but it also is used
for making constants of one namespace visible into another namespace, for
example making PI of Math visible as just PI somewhere else, instead of
Math::PI.

> Ruby/GTK says I need "require 'gtk2'" where as tutorials say I have to
> do include Math. I guess this is a different between classes and
> modules.

no, require is about loading files. if you come from Perl, then chances
are you've learned that a module is a Perl file, and a class is a kind of
package. This is not the case with Ruby, where what is called a module is
almost the same as a class, and both modules and classes are kinds of
objects, and a Ruby file is just called a file, or a program.

There are some differences in vocabulary. Beware of them.

________________________________________________________________
Mathieu Bouchard                       http://artengine.ca/matju