From: Florian Gross Date: 2004-06-06T11:38:40+09:00 Subject: Re: How to ducktype a Hash? Sean O'Dell wrote: > No, it IS my problem. My code quietly does some really undesired things when > non-hash-like objects get to this one point in code. I hate this attitude > about typing. I know you mean well, and it's been talked out to death, but I > don't buy the whole thing about "if it has the methods, it must be fine." > It's clearly NOT fine. If an array or a string, both which have the [] > methods I need, get to this one place, I drop a whole branch of data being > passed around. The ideal is to catch it as an error, and remedy the > situation by finding out how the data came in that way in the first place and > prevent it, or perhaps just detect it and perform some special case. As it > is, I can't tell for sure when an object really DOES act like a hash. I think what you're getting at is this: Duck typing isn't really "quacks like a duck", but rather "quacks" in its current state. Maybe it would be an interesting thing to be able to take a set of unit tests and dynamically run them on the Object that you're getting...? Regards, Florian Gross