At 08:48 PM 4/13/01 +0900, ts wrote: > >>>>> "L" == Luigi Ballabio <luigi.ballabio / riskmap.net> writes: > > Add > > >> class One > >> def + (x) > >> x+1 > >> end > > def coerce(x) > [x, 1] > end > > >> end > >L> Sort of __radd__ in Python? > > it will work also with '3 * one' and 'one * 3' if you define 'def *(x)' > (or with -) Hmm. Looks like I kept my example too simple. The real picture is, I have a TridiagonalOperator class written in C++ and exported to Ruby through SWIG. Not easy to coerce to a Float :) I export the operator * (a matrix times a scalar) and I hoped I could get scalar*matrix for free. Oh well... Thanks anyway, Luigi