From: "ara.t.howard" Date: 2007-10-23T02:44:45+09:00 Subject: Re: Conflicts between using respond_to? and extending Ruby On Oct 22, 2007, at 11:26 AM, David A. Black wrote: > >> case obj >> when Array >> ... >> >> is safer and more accurate. i think it really depends on the use >> case - i personally use both. > > It does indeed depend; they do totally different things. not entirely - they both allowing pre-testing to see if code is going to work or explode... > I was > describing the differences, specifically in the context of duck typing > (or alternatives to duck typing): respond_to? gives you information > about an object at a given moment, and kind_of? tells you about its > ancestry. well sortof: OpenStruct.new.respond_to?(:foo) #=> false OpenStruct.new.foo() #=> nil as i said, i think it's 100% situational and you really can't make blanket rules. cheers. a @ http://codeforpeople.com/ -- it is not enough to be compassionate. you must act. h.h. the 14th dalai lama