Project

General

Profile

Bug #12216

Updated by nobu (Nobuyoshi Nakada) about 8 years ago

Dear Ruby Lang developers. 

 I would like to ask about why the following code can work?  

 Or is it a valid scenario and "as expected" behavior to ignore public call on a protected method.  

 Thank you guys for the brilliant! 


 <pre><code class="ruby"> 

 ```ruby 
 class A 
   

   class << self 
     

     def inherited(klass) 
       p klass.protected_method_call 
     end 

     protected 
     def protected_method_call 
       self.to_s 
     end 
   end 
 

 end 

 


 class B < A 
 

 end 

 # output: "B" 
 ``` 
 

 </code></pre>

Back