From: Michael Edgar Date: 2011-07-24T06:05:57+09:00 Subject: Re: Top level function definition gets in Kernel module? On Jul 23, 2011, at 4:57 PM, Jean-Pascal Billaud wrote: > irb(main):001:0> def test_fun > irb(main):002:1> end > => nil > irb(main):003:0> p Object.instance_methods.sort > [...] > singleton_methods", "taint", "tainted?", "tap", "test_fun", "to_a", > "to_enum", "to_s", "type", "untaint"] > => nil > irb(main):004:0> p Kernel.methods.sort > [...] > "tainted?", "tap", "test", "test_fun", "throw", "to_a", "to_enum", > "to_s", "trace_var", "trap", "type", "untaint", "untrace_var", "warn"] > => nil You wrote Kernel.methods, not Kernel.instance_methods. Kernel.methods returns the names of all the methods on the Kernel object itself. "Kernel" is a reference to an object of class Module, which is a subclass of Object. Thus, since test_fun is an instance method on Object, and Kernel is an instance of a subclass of Object, it has access to that method as well. I think you were confused between Kernel.methods and Kernel.instance_methods. Kernel.instance_methods does not include "test_fun" given this example, as expected. Michael Edgar adgar@carboni.ca http://carboni.ca/