From: Phillip Hutchings Date: 2006-06-28T11:46:26+09:00 Subject: Re: Why Include and Require? On 6/28/06, Mark Sargent wrote: > HI All, > > with our volunteer teacher absent last night, our class was left to ponder > things for ourselves. We were looking at a ruby equivalent for cp and came > upon something that we all didn't understand. In the below code, small as it > may be, > > #!/usr/local/bin/ruby > > require 'fileutils' > include FileUtils::Verbose > cp("methround.rb", "newmethround.rb") > > > we wondered why we required to use require and include before the code would > work. Naturally, if we removed the, "::Verbose" it still worked. Why require > and then include fileutils? Cheers. > > Mark Sargent. > > require loads the files, include includes a module in to a class. In this case you're including FileUtils::Verbose in to the Object class. Removing Verbose works as FileUtils also includes cp, but ::Verbose uses the Verbose version of cp. -- Phillip Hutchings http://www.sitharus.com/