Project

General

Profile

Bug #10092

Updated by nobu (Nobuyoshi Nakada) over 9 years ago

Let’s consider the following code: 

 ~~~ruby ~~~ 
 module M 
   extend self 
   def m_i  
     puts "m_i" 
   end  
   def m 
     puts "include? = [#{singleton_methods.include?(:m_i)}]" 
     puts "call = [#{singleton_method(:m_i).call}]" rescue puts $! 
   end  
 end 
 ~~~ 

 it prints: 

 ~~~ruby ~~~ 
 # include? = [true] 
 # undefined singleton method `m_i' for `M' 
 ~~~ 

 The method is listed under `singleton_methods` while the call to it via `singleton_method` raises an error.

Back