From: Rick DeNatale Date: 2007-11-11T02:28:38+09:00 Subject: Re: top-level methods and constants On Nov 10, 2007 12:10 PM, Xavier Noria wrote: > A couple of questions regarding the top-level environment of execution. > > * The Pickaxe says on page 376 that top-level methods are defined as > private instance methods of Object, whereas Ruby for Rails says on > page 203 they are private instance methods of the Kernel module. Which > one is correct? Looks like the pickaxe: def foo end self.private_methods.include?("foo") # => true Object.private_instance_methods(false).include?("foo") # => true Kernel.private_instance_methods(false).include?("foo") # => false Note though that in irb top level methods are public: irb(main):001:0> def foo irb(main):002:1> end => nil irb(main):003:0> irb(main):004:0* self.private_methods.include?("foo") => false irb(main):005:0> Object.private_instance_methods(false).include?("foo") => false irb(main):006:0> Kernel.private_instance_methods(false).include?("foo") => false irb(main):007:0> Object.instance_methods(false).include?("foo") => true irb(main):008:0> -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/