On Oct 22, 5:09 pm, "ara.t.howard" <ara.t.how... / gmail.com> wrote:
> as i was mentioning to david, my experience is that it just depends:
> if you are writing something like
>
>    case conn
>      when TCPSocket
>      when UDPSocket
>    end
>
> then is_a? is probably pretty strong - as strong as it possible in
> ruby since we can always
>
>    def class() Lie end

Maybe I'm misunderstanding your point, but that doesn't do much.

>> x = [1,2,3]
=> [1, 2, 3]
>> x.is_a?(Array)
=> true
>> x.class
=> Array
>> def x.class() String; end
=> nil
>> x.class
=> String
>> x.is_a?(Array)
=> true
>> case x
>> when Array then 'arr'
>> when String then 'str'
>> else 'blah'
>> end
=> "arr"

I ran into this when I thought I was going to be able to use mock/stub
objects and handle is_a?/kind_of?/&c calls by stubbing the response to
class.

--
-yossef