From: Siep Korteling Date: 2008-11-11T07:55:57+09:00 Subject: Re: Problem with object methods? Carter Davis wrote: > Yeh, I think I understand. One last thing, though. Say I have this code: > > class FirstClass > def initialize > puts "YAY INITIALIZE!" > end > > def text > puts "Yay more text!" > firstClass.method > end > > def method > puts "This is what I want it to show." > end > end > > firstClass = FirstClass.new > firstClass.text > > In which I want it to execute the "text" method, and then, right after > that, execute the "method" method. Now, if I were to run THIS code, it > would throw an error, saying that the 'firstClass' variable or method is > undefined. > > How could I make the function execute another method within the same > object? Try this: class FirstClass def initialize puts "YAY INITIALIZE!" end def text puts "Yay more text!" method # or self.method end def method puts "This is what I want it to show." end end firstClass = FirstClass.new firstClass.text hth, Siep -- Posted via http://www.ruby-forum.com/.