Project

General

Profile

Bug #13446

Updated by nobu (Nobuyoshi Nakada) over 7 years ago

~~~ruby ~~~ 
 using Module.new { 
   refine Enumerable do 
     alias :orig_sum :sum 
   end 
 } 

 module Enumerable 
   def sum(*args) 
     orig_sum(*args) 
   end 
 end 

 class GenericEnumerable 
   include Enumerable 

   def each 
   end 
 end 

 # GenericEnumerable.new.sum # if we uncomment this line, `GenericEnumerable#sum` will work 
 Enumerable.prepend(Module.new) # if we comment out this line, `GenericEnumerable#sum` will work 

 p GenericEnumerable.new.sum # undefined method `orig_sum' for #<GenericEnumerable:0x0000000127c120 @values=[1, 2, 3]> (NoMethodError) 
 ~~~ 

 Is this intentional?

Back