Project

General

Profile

Bug #10060

Updated by nobu (Nobuyoshi Nakada) almost 10 years ago

~~~ruby ~~~ 
 class Bug 
   def initialize 
     self.n = 1 # ok 
   end 

   def t1 
     self.n = n + 1 # ok 
     self.n += 1 # in `t1': private method `n' called for #<Bug:0x000000019ae1a0 @n=2> (NoMethodError) 
   end 

   def t2 
     n # ok 
     self.n # in `t2': private method `n' called for #<Bug:0x0000000218a360 @n=1> (NoMethodError) 
   end 

   private 

   attr_accessor :n 
 end 
 ~~~

Back