From: ts Date: 2001-07-15T16:54:05+09:00 Subject: [ruby-talk:17873] Re: Overloaded methods >>>>> "H" == HarryO writes: H> I was reading last night about perl's multimethods module and thought it H> would be interesting to see if that approach was do-able in Ruby. The approach of the P language is weird (bad syntax for me) and *slow*. If you really want to look at multi-methods, look at dylan or parasitic method of j*v* Just an example (it's important to see that next_method is a private method) pigeon% cat b.rb #!./ruby class AA < Array end class A def tt(Array a) yield "Array" next_method end def tt(AA a) yield "AA" next_method end def tt(String a) yield "String" next_method end private def tt(Enumerable a) yield "Enumerable" end end p A.instance_methods p A.private_instance_methods a = A.new a.tt(AA.new 1, 2) {|i| puts "received #{i}" } a.tt("string") {|i| puts "received #{i}" } a.tt(1 .. 2) pigeon% pigeon% b.rb ["tt"] ["next_method", "tt"] received AA received Array received Enumerable received String received Enumerable ./b.rb:31: private method `tt' called for # (NameError) pigeon% Guy Decoux