Thanks much, Dave! I'm a little in the dark about singleton methods. I'm not sure when one would use one instead of an instance method. BTW< That must be some kind of record for a speedy response. If you had been any faster, I would have received the reply before I asked the question. Are you using a time machine? I had actually thought it might be hours till I got an answer... most of the people on this list are asleep right now, aren't they? Hal > h.fulton / att.net writes: > > > Greetings, fellow Ruby enthusiasts. > > > > Perhaps I have a fundamental misunderstanding here. > > Perhaps.. ;-) > > When you defined Object.foobar, you're creating a singleton method in > Object (one that should be called as Object.foobar), not an instance > method. Thus the method is not available through a message to self. > > So, you could rewrite it as an instance method, and all's fine. (I > also used the wonderful 'defined?' expression to check for foorbar in > a superclass. > > class Object > def foobar > print "I am the ultimate foobar!\n" > end > end > > class Foo > def foobar > print "I am Foo::foobar... " > if defined? super > print "my parent has a foobar!\n" > super > else > print "my parent does NOT have a foobar.\n" > end > print "My parent is ", self.type.superclass, "\n" > end > end > > Foo.new.foobar > > -- > Thomas Consulting. > Innovative and successful developments with Unix, Java, C, and C++. > > Now in bookstores: > The Pragmatic Programmer. www.pragmaticprogrammer.com/ppbook/