From: Josh Cheek Date: 2010-10-01T06:00:09+09:00 Subject: Re: How to prevent overwriting methods by accident? --001485f90df6db4d970491805cab Content-Type: text/plain; charset=ISO-8859-1 On Thu, Sep 30, 2010 at 2:53 PM, Alex Stahl wrote: > But is there a way to call the original method instead of just quitting > out? > > The super keyword does this, I'm not really sure what it is, a macro maybe? I just think of it as a function I have available in overridden methods, like block_given? Be aware that unless you specify its args, it will pass whatever params the method originally received. class Parent def self.ruby!(arg = nil) puts "Parent.ruby!(#{arg.inspect})" end end class Child1 < Parent def self.ruby!(arg) super puts "Child1.ruby!(#{arg.inspect})" end end class Child2 < Parent def self.ruby!(arg) super(12) puts "Child2.ruby!(#{arg.inspect})" end end class Child3 < Parent def self.ruby!(arg) super() puts "Child1.ruby!(#{arg.inspect})" end end Child1.ruby!( :abc ) puts Child2.ruby!( 'abc' ) puts Child3.ruby!( /abc/ ) --001485f90df6db4d970491805cab--