From: Joel VanderWerf Date: 2001-10-08T04:54:52+09:00 Subject: [ruby-talk:22209] Re: Ruby and multiple inheritance ts wrote: > > >>>>> "P" == Paul Brannan writes: > > P> module Base > P> def foo > P> puts "Base" > P> end > > module_function :foo > > P> end > [...] > P> def foo > P> super # How can I specify that I want to call Base's foo()? > > Base.foo > > P> puts "Derived" > P> end > P> end > > P> d = Derived.new > P> d.foo > > Guy Decoux Base#foo called in this way cannot affect the instance vars of Derived. You can only do that with super or another method, not a module_function: module Base def foo puts "Base" @x = 1 end module_function :foo end class Derived include Base def foo Base.foo puts "Derived" puts @x end end d = Derived.new d.foo # output: # Base # Derived # nil def Base.bar puts @x end Base.bar # output: # 1 -- Joel VanderWerf California PATH, UC Berkeley mailto:vjoel@path.berkeley.edu Ph. (510) 231-9446 http://www.path.berkeley.edu FAX (510) 231-9512