Hi -- On Mon, 7 Jun 2004, Jean-Hugues ROBERT wrote: > Hi, > > This may be somehow stupid but what about simply inheriting > from Hash ? > > In the worst case you aren't going to use the hash default > implementation at all, because you would provide your own > implementation for the storage. But that case is not that bad, > because I suspect that the overhead is very very small. > > class MyObject < Hash > def [](key) > my_ultra_efficient_get( key) > end > end > > Then you can kind_of? Hash as usual. I think this didn't come up because Sean was asking more about duck typing (rather than the kind_of? approach). But the matter of inheriting from built-ins is an interesting one in its own right. I've always liked it; it never bothered me that my objects had "extra" methods, since most objects have methods I never use anyway. But that objection has been raised by lots of people, though I've never quite understood the rationale. David -- David A. Black dblack / wobblini.net