From: "Steve P." Date: 2010-07-27T09:41:37+09:00 Subject: Re: Confused with "include" and require Florian, As you indicated, I put my classes in files and then require'd, them and it works, of course. I guess as I attain experience, the seeming restrictive way that "require" works, will seem great. I was naive in thinking that arbitrary code could be "include"-ed. Best Regards Steve. Florian Gilcher wrote: > On Jul 26, 2010, at 8:40 PM, Steve P. wrote: > >> /home/holocene/ruby/questionsaddquestions.rb:10: undefined local >> >> Why am I getting an error? I thought "load" essentially is a substitute >> for keyed text, as opposed to 'require'. > > From the documentation of 'load'[1]: > > "In no circumstance will any local variables in the loaded file be > propagated to the loading environment." > > There are other, better ways to do this for example by separating your > logic into classes and then get the program going from a small main > program. Any tutorial about moderately complex ruby programs should > illustrate how to do this. > > require and load do not behave like PHPs #include at all. > > Regards, > Florian > > [1] http://ruby-doc.org/core/classes/Kernel.html#M005940 -- Posted via http://www.ruby-forum.com/.