On Wed, 8 Mar 2006, email@example.com wrote:
And another file driver.rb has following code
The whole idea of “local” variables is to be local If you want
something to be visible between files, you should make it a constant
or a method:
class MyClass < Food
myvariable = M.myvalue
or something like that.
Also, if you can tell me what exactly is the difference between require
and include, that would be great help. I don’t see any clear
explanation anywhere for the above.
“require” reads in a file (either a Ruby file or a compiled file for a
C extension). “include” mixes a module into a class or into another
module. So the usual sequence is require, then include: first you
read in the file that defines a module (like M in my example), then
you do something with the module (in my example I just used a method
in it, but you can also “include” modules).
David A. Black (firstname.lastname@example.org)
Ruby Power and Light, LLC (http://www.rubypowerandlight.com)
“Ruby for Rails” chapters now available
from Manning Early Access Program! http://www.manning.com/books/black