From: Sean O'Dell Date: 2004-06-06T09:24:26+09:00 Subject: Re: How to ducktype a Hash? On Saturday 05 June 2004 13:30, Dave Thomas wrote: > On Jun 5, 2004, at 13:43, Sean O'Dell wrote: > > It's not my classes that are the problem, it's all of the other > > objects that > > respond to [] and []=, but which aren't hash-like (they're array-like, > > and > > even then it's anyone's guess as to the functionality). > > Then it's not your problem! Code on, young turk. 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. Sean O'Dell