Flowdock
<(p1) public

Returns true if mod is a subclass of other. Returns nil if there’s no relationship between the two. (Think of the relationship in terms of the class definition: “class A<B” implies “A<B”).

Show source
Register or log in to add new notes.
January 11, 2010
0 thanks

Includes descendants

May be helpful to know that this returns true if A is any descendant of B, not just a direct one. As an example:

class Foo; end
class Bar < Foo; end
class Baz < Bar; end

Bar < Foo #=> true
Baz < Foo #=> true

If you want direct descendance try Class#superclass:

Bar.superclass == Foo #=> true
Baz.superclass == Foo #=> false