From: Daniel Finnie Date: 2006-12-18T02:50:42+09:00 Subject: Re: require, load and include --- what's the difference? I think you've got it right. require basically copies and pastes the referenced file into the source, but it only includes classes and modules, I don't think variables besides instance variables and class variables get imported. include makes it so you don't have to use the scope resolution operator "::". It "unwraps" a module is how I like to think of it. matt wrote: > Hello, > > I'm browsing through some code, trying to familiarize myself with the > language (I have a C++ background, with only a #include), and I realize > that there are 3 calls that I'm trying to wrap my head around. > > Here's my stab: > > Require -- seems to include another file to gain access to other > classes, modules, and global data. This seems to be equivalent to a C++ > include, with inclusion guards > > Load -- seems to be the same as require, but will actually reload the > data every time it is called, where require will load once and cache the > file. This seems to be equivalent to C++ include, with out inclusion > guards. > > Include -- seems to include a module name from a pre-determined path, > but not classes (unless encapsulated within a module). Would this be > similar to a C++ namespace being given the include directory at compile > time? > > So a couple of things here, are my understandings of the 3 methods > close, if not, could someone please expand on them. The other is what's > the advantage of include vs require? I mean, why would I include a > module, rather than require it's filename? > > I've read through the RDocs, but I still don't seem to understand. > > I hope this post makes sense, let me know if I need to clarify. > > Thanks > > Matt > > > > > > > >