From: Brian Candler Date: 2011-04-08T01:06:39+09:00 Subject: Re: Hash Surprises with Fixnum, #hash, and #eql? Phillip Gawlowski wrote in post #991471: >> If you see inheritance as "is a" relationship then inheritance would >> be Rational < Real < Complex but not the other way round. Otherwise >> you cannot use a subclass instance everywhere you were using a >> superclass instance. > > Though, does the "is a" relationship hold up? I think it's more of a > "kind of" relationship, where subsequent classes are defined in ever > more detail (so, you'd inherit Floats from Integers, and Complex from > Float). Isn't this the old "ellipse is_a circle, or vice versa" debate? If you make Circle the top class, then Ellipse reimplements pretty much everything (draw, area, etc); there's no useful code sharing. If you make Ellipse the top class, then Circle is just a special constrained case of Ellipse. Translating to the current discussion, substitute Float for Circle and Ellipse for Complex. Ruby's answer is: neither is a subclass of the other. Both inherit from Numeric. That is, Circle and Ellipse are both a Shape. Or in other words, "who cares"? Eventually you come to realise that a lot of what is taught in object oriented classes and textbooks is tosh :-) -- Posted via http://www.ruby-forum.com/.