From: Simen Edvardsen Date: 2006-10-28T07:48:40+09:00 Subject: Re: classless methods On 10/28/06, srdjan.m wrote: > Trans wrote: > > Not Kernel, it becomes a private method of Object class. > > def widget(tidbit) > tidbit > end > > I was under the impression that the widget(tidbit) method becomes a > private method of Kernel not Object. > > def hello > "hello" > end > > class Object > def hello2 > "hello2" > end > private_class_method :hello2 > end > > Object.private_methods.include?("hello") => true > Object.private_methods.include?("hello2") => true > > Kernel.private_methods.include?("hello") => true > Kernel.private_methods.include?("hello2") => false > > The code above demonstrates that hello is private to both Kernel and > Object as opposed to hello2 which is only private to Object. > > Am I making a silly deduction mistake somewhere? > I thought it was added to Kernel too, but it appears not to be the case: # test.rb module Kernel def self.method_added(m) puts "#{m} added to Kernel" end end class Object def self.method_added(m) puts "#{m} added to Object" end end def x end $ ruby test.rb x added to Object > srdjan > > > -- - Simen