From: James Gray Date: 2008-04-07T00:21:54+09:00 Subject: Re: Is possible to define various methods at same time? On Apr 6, 2008, at 9:56 AM, Iñaki Baz Castillo wrote: > El Domingo, 6 de Abril de 2008, Phillip Gawlowski escribió: > >> >> Have you looked at #method_missing, and it's relatives, like >> #instance_variable_set? > > Ok, but my purpose was in fact: > > def method1, method2 (args) > ... > super <-- so it call to "method1" or "method2" depending > ... > end Here's one way you might go about that: class Parent def example1 puts "In example 1." end def example2 puts "In example 2." end end class Child < Parent %w[1 2].each do |suffix| define_method("example#{suffix}") do puts "Forwarding to example #{suffix}..." super end end end c = Child.new c.example1 c.example2 __END__ Hope that helps. James Edward Gray II