From: Eric Christopherson Date: 2012-02-06T10:00:20+09:00 Subject: Re: inheritance one more time On Sun, Feb 5, 2012 at 4:48 PM, luk malcik wrote: > Hi, similar topic was here but still I can't do that. This is my code: > > Square = Struct.new(:x,:y,:a) do > >   include Domieszka > >   def pole > >   p = a**2 > >   end > >   def obwod > >   o = 4*a > >   end > >   def pole=(a) > >   self.a = a > >   end > >   def obwod=(a) > >   self.a = a > >   end > > end > > > > class Rectangle >   include Domieszka > >   def pole=(b) > >   self.b = b >   end >   def pole >   p=a*b > >   end > > > > Why there is no possibility to write : > r = Rectangle.new > r.pole = 3 > "Undefinied method error..." > > Domieszka is module declared at the beginning of my code, I dont put it > here I'm not sure what's in your Domieszka module, but in the code you pasted, there are no methods b or b= in Rectangle; and there are no methods a or a= in Square. The missing Rectangle#b= is why r.pole = 3 doesn't work. Also, since you include Domieszka in the superclass, there's no need to include it again in the subclass.