From: "David A. Black" Date: 2009-02-08T22:44:43+09:00 Subject: Re: Module#=== vs Object#is_a? Hi -- On Sun, 8 Feb 2009, Robert Dober wrote: > On Sun, Feb 8, 2009 at 12:27 AM, David A. Black wrote: >> >> if car.make == make >> >> than >> >> if make === car > Although I am a big fan with using #=== (for fingerlazyness) I have to > agree, after some months of thinking and reading it is probably a bad > idea to use it too much. > > I am still not sure for some special cases as e.g. > instance_of_Class === object > or > instance_of_Regex === string > these idioms have some good points too e.g. auto-documenting case > behavior and forcing nubies to learn about #===. I don't think it's the right approach to learning, though. I'd rather see the best possible code, and let people learn from that. No one is going to really learn about #=== (the fact that it's the case equality operator, etc.) just by seeing examples of its explicit use. > However I really do have a strong opinion ( very loosely hold of course! ) about > make === car > and > car.make == make > . > > I would think that if one accepted the first idiom in a project it > really should convey a very, very strong message, something so > intrinsic to the problem space that a special idiom is justified. > In the general case I agree with David though. I'm not sure you need a "though"; that's essentially the point I was making :-) David -- David A. Black / Ruby Power and Light, LLC Ruby/Rails consulting & training: http://www.rubypal.com Coming in 2009: The Well-Grounded Rubyist (http://manning.com/black2) http://www.wishsight.com => Independent, social wishlist management!