From: Eric Christopherson Date: 2013-03-08T07:29:11+09:00 Subject: Re: methods in subclasses On Thu, Mar 7, 2013 at 3:42 PM, john rxjmo wrote: > Hi, > I'm new to ruby programming and I want to ask you if you can help me on > this. > I have created 3 classes (c1, c2, c3) and I want to do 3 sublasses (sc1, > sc2, sc3). > > the classes are related. > > I want to define a method in cs1 (uses variables and methods from c1) > and use it from sc2. > > When I run the module I get this error: > I get this error : "NoMethodError: undefined method `r180' for > # > > sample code: > class sc2 < c2 > # this method (m1) is defined in c2 > def m1 > super > # I want to add this part > # @b: defined in c2 as an instance of c1 > @r.bind('u', proc {@b.r180}) > end > end > > class sc1 < c1 > # I added this method > def r180 > # go, @gir, @cb.m() and d() are defined > # in c1 > if !go? and @gir? > @cb.m() > end > d() > end > end Is r180 actually defined in c1? It would be easier to help if we could see c1 and c2.