From: Sean O'Dell Date: 2004-06-22T02:35:42+09:00 Subject: Re: About top-level method On Monday 21 June 2004 10:23, Sam Sungshik Kong wrote: > 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. My guess is irb ignores the private flag to allow you to test what you wish from irb. It's really just a debugging environment, so it makes sense to disable private flags. Sean O'Dell