From: Harry Ohlsen Date: 2001-12-11T09:02:13+09:00 Subject: [ruby-talk:28156] Re: The benefits of dynamic typing? In article <20011211.105127.461152493.1860@zip.com.au>, "Harry Ohlsen" wrote: > You can make this work the way you want (although, you'd have to stick > this code in a module and "require" it in all your code). Note that I'm > not known for writing the simplest version of things, so someone else > will probably have to clean it up for me (and I've only done the 1 + "1" > case for Fixnum; it would probably have to be coded more generally to be > useful) ... Actually, this makes me wonder ... is there a method somewhere that lets me find out whether a given object's class is a descendent of a given class? If not, one could definitely write such a thing, by running up the superclass hierarchy. The reason I ask is that all of the numeric classes are presumably derived from some base numeric class, so would that make it possible to write the Fixnum case I had in the previous post more in a more general manner? However, I also wonder how one would do the generalisation. What class would I make the change to, in order to catch calls to +() on all objects of ANY numeric type? Maybe this just isn't possible, and on would need to do the same redefinition of +() for every numeric type. Kind of messy, but I guess if you really want this behaviour, there's a price to pay :-).