From: nobu.nokada@... Date: 2001-12-29T09:20:44+09:00 Subject: [ruby-talk:29605] Re: extending method of class A to support arguments of class B by promoting `self' to class B At Sat, 29 Dec 2001 07:53:38 +0900, Tomasz Wegrzanowski wrote: > Class Real has method `*' that can use argument Real. > > I make class Complex. Class Complex also > has function `*' which can take either Real or Complex argument. > Object Complex can be created from Real by Complex.new(real_object). > > I want to tell Ruby, that when Real object is called with Complex > argument it should be promoted to Complex and then appropriate > Complex method be called. Define Complex#coerce if you mean only Numeric classes. See lib/complex.rb for complete codes. class Complex def coerce(real_object) [Complex.new(real_object), self] end end Otherwise, if you mean generic classes, there's no such framework now. Nobu Nakada