From: Austin Ziegler Date: 2003-11-21T04:41:25+09:00 Subject: Re: "stereotyping" (was: Re: Strong Typing (Re: Managing metadata about attribute types) ) On Thu, 20 Nov 2003 16:02:14 +0900, Thien Vuong wrote: > Austin Ziegler wrote: >>> I do wonder what functional purpose does "kind_of?" serves now >>> that it was severely denigrated in the language - should it be >>> deprecated/ removed? since it is considered totally bad style to >>> use. >> I don't think that it's totally useless. I do think that it's of >> extremely limited utility. > Could you give me an example of what is considered a good use > then? Given the presumption that object classification and > knowledge is bad, what good information could be gained from > knowing it? Note that what follows is my opinion only: * Checking against your own types. See Ruwiki's lib/ruwiki.rb lines 81 and 193. * Distinguishing between Array, Hash, and String in times when such distinctions are necessary (e.g., #each). * This example from MIME::Type: def <=>(other) #:nodoc: if other.respond_to?(:content_type) @content_type <=> other.content_type elsif other.kind_of?(String) @simplified <=> Type.simplified(other) else @content_type <=> other end end There's not a lot of examples where I use #kind_of? in my code. -austin -- austin ziegler * austin@halostatue.ca * Toronto, ON, Canada software designer * pragmatic programmer * 2003.11.20 * 14.18.00