From: Sam Sungshik Kong Date: 2004-06-22T02:23:13+09:00 Subject: Re: About top-level method Hi, Sean! Thank you for the reply. You helped me understand half of the issue. As Object is a superclass of all classes (except for Object), if I add a method to Object, the metaclass of Object will have it too. That enlightened me a lot. However, there's one more thing to solve. When I define a method at top-level, it's Object's private instance method. So it can't be used like receiver.method. obj.my_f #-> Error because my_f is private. Object.my_f #->Error because my_f is private. The question is why irb ignores the error? Is it intentional or a bug? I also appreciate all other replies. kong "Sean O'Dell" wrote in message news:200406210824.11465.sean@celsoft.com... > On Sunday 20 June 2004 22:33, Sam Sungshik Kong wrote: > > Hello! > > > > I'm reading a book named "Teach yourself Ruby". > > In chapter 2, it says that top-level methods are Object's private instance > > methods. > > But my test shows different results. > > > > In irb, I tested it like the following. > > > > def my_f > > p "my_f" > > end > > > > Object.my_f #=> print "my_f" > > obj = Object.new > > obj.my_f #=> print "my_f" > > > > Then, my_f is an instance method, and a class method as well? > > > > Can anyone help me understand it? > > The Object class is the base of every other class, and is itself an instance > of class Class. > > Sean O'Dell > > >