From: Chris Pine Date: 2003-02-12T05:31:15+09:00 Subject: Re: inheriting from base classes ----- Original Message ----- > > I'm not sure I understand what you mean. `kind_of?' determines what > I'm not sure I understand that last point, but in any case, Whoops, didn't mean to sound like I was mocking your phrase :-) ---------------------------- :) Well, I think we might be talking about different things, so our mutual confusion is understandable. What I meant by `kind_of?' determining what methods an object has is that every method `obj' responds to comes from some class `aClass' such that: obj.kind_of? aClass # --> true Even if it's just a singleton class: irb(main):001:0> x = Object.new # irb(main):002:0> sc = class << x; self; end #> irb(main):003:0> x.kind_of? Object true irb(main):004:0> x.kind_of? sc true It's the relationship conveyed by the `kind_of?' method that I was referring to. An object is a `kind_of?' many different classes and modules, but it's behavior is *completely* determined by which ones. > I interpret Matz's words very differently. I think what he was saying > is that inheritance, in Ruby, can be viewed as not so much a > hierarchical thing but a kind of borrowing of functionality. Oh. Interesting. I thought he was saying that one should often use 'borrowing of functionality' (like mixins, singleton classes, etc) instead of forcing everything into an inheritance heirarchy. It's also quite possible that we are both taking him out of context... but that's what I think, anyway, even if it's not what he thinks. :) Chris