Class.descendant_of?

Noob question:

class A; end
class B < A; end

B.kind_of?(A)

Is there a method that will return true if the class is a descendant of
that class?

Thanks for your help.

On Tue, Sep 2, 2008 at 8:14 PM, Ben J. [email protected]
wrote:

Thanks for your help.
class A; end
class B < A; end
B.ancestors.include?(A)
=> true

Todd

2008/9/3 Ben J. [email protected]:

Noob question:

class A; end
class B < A; end

B.kind_of?(A)

Is there a method that will return true if the class is a descendant of
that class?

class A; end
class B < A; end

B < A
=> true

Regards,

Park H.

From: Ben J. [mailto:[email protected]]

Is there a method that will return true if the class is a

descendant of that class?

descendant is quite a generic term :wink:

compare,

B.ancestors.map {|b| [b, B < b]}
#=> [[B, false], [A, true], [Object, true], [Kernel, true]]

B.ancestors.map {|b| [b, B.superclass == b]}
#=> [[B, false], [A, true], [Object, false], [Kernel, false]]

kind regards -botp