Sean O'Dell wrote: >On Saturday 05 June 2004 13:30, Dave Thomas wrote: > > >>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. > > The problem Sean is that even if you know the method has the right signature you can't guarantee it has the same functionality. It remains an exercise for the person that wrote the contorted object and is passing it in to figure out how to make it work with your code. If it needs to be more hash-like, then let him figure out he needs to pass a hash. If he can get his weird object to work without it actually looking or acting like what you think a hash should look like, why penalize him because he doesn't implement it in a certain way? -- John