From: Venkat Akkineni Date: 2009-07-17T15:37:06+09:00 Subject: Re: trouble with puts Gary Wright wrote: > On Jul 17, 2009, at 2:09 AM, Venkat Akkineni wrote: >> >>> ruby something.rb >> >> # I don't see the expected Output >> >> >> Could somebody throw some light on this. > > Code that is within a method definition doesn't get > executed until an instance is created and the method is > called. > > Add the following to your third example after the class > definition block for Something: > > Something.new.print_something > > Gary Wright Thanks for replying Gary and stefano I have already tried to create an instance only to get the following error NameError: uninitialized constant Test This I assume is thrown because the interpreter cannot find the file. I ran the irb command from inside the folder containing this file. Doesn't irb see the file? Addressing what steffano said, Well I have called the print_something method from inside the class's constructor. Should I not assume that when the file is run the class's constructor will be called and hence the method will be called. Thanks Venkat -- Posted via http://www.ruby-forum.com/.