From: Gavin Sinclair Date: 2004-06-07T02:19:32+09:00 Subject: Re: How to ducktype a Hash? On Monday, June 7, 2004, 2:42:06 AM, Sean wrote: > A type would say something like: > All hashes have a method called each_pair that takes no parameters and calls > the given block once for each key/value pair the hash contains. > Now, for brevity, consider that the entire type description for a Hash. What > we have now is a "hash type." The Hash class itself can still change it's > methods, including its each_pair method, but if it ever strays from the > description of a hash type, it is no longer a hash type. > If Hash tagged itself as complying with the "hash type" you could depend on > certain methods doing certain things and taking a certain number of > parameters. What if a class tags itself as a "hash type" but an instance of it redefines a method in a way that contradicts that type? I'm not being alarmist, but your messages have shown a great deal of concern for knowing that an object does what it advertises. How do you see the above scenario, then? I don't think your idea is a bad one, by the way. Gavin