From: john rxjmo Date: 2013-03-08T17:11:36+09:00 Subject: Re: methods in subclasses No, r180 is not defined in c1, only in the subclass sc1 class c3 def initialize (pa, b) @alr = pa @ri = (0..(@alr.size-1)).to_a.sample @c = AC.sample @bp = [5, 0] @b = b @moved = true end ... end ============================================= class c2 def initialize @r = TRoot.new @t = TTimer.new set_b @running = true m1 buttons rg end ... def m1 @r.bind('n', proc {self.ng}) @r.bind('p', proc {self.pause}) @r.bind('q', proc {exitProgram}) @r.bind('a', proc {@b.mle}) @r.bind('w', proc {@b.rcc}) end end ================================================ class c1 def initialize (g) @gr = Array.new(nr) {Array.new(nc)} @cb = c3.np(self) @sc = 0 @ga = ga @delay = 500 end ... # this fucntion is like the I wanna add to my subclass def rcc if !go? and @gir? @cb.m() end d() end end -- Posted via http://www.ruby-forum.com/.