From: dblack@... Date: 2007-03-02T11:26:30+09:00 Subject: Re: Duck Typing Hash-Like Objects Hi -- On Fri, 2 Mar 2007, Gary Wright wrote: > On Mar 1, 2007, at 7:38 PM, James Edward Gray II wrote: >> You're still type checking, you're just doing it in a more fragile way. >> If you want to type check, use the class, I say. > > Yet if I test for (Hash == mystery_obj) that would not > allow someone to pass an RBTree object instead, which I think > is a very reasonable thing to allow and works just fine if > I only use #fetch. I had the impression James was talking about the Integer and String methods, though then again those aren't actually the classes. So I'm not sure what he meant :-) But I don't think it was just to test class membership, since that manifestly doesn't help in the kind of situation you're describing. David -- Q. What is THE Ruby book for Rails developers? A. RUBY FOR RAILS by David A. Black (http://www.manning.com/black) (See what readers are saying! http://www.rubypal.com/r4rrevs.pdf) Q. Where can I get Ruby/Rails on-site training, consulting, coaching? A. Ruby Power and Light, LLC (http://www.rubypal.com)