Get ancestors : ancestors « Reflection « Ruby






Get ancestors


p String.ancestors          # => [String, Enumerable, Comparable, Object, Kernel]
p Array.ancestors           # => [Array, Enumerable, Object, Kernel]

class MyArray < Array
end

p MyArray.ancestors         # => [MyArray, Array, Enumerable, Object, Kernel]
p Object.ancestors          # => [Object, Kernel]

class MyClass
end
p MyClass.ancestors         # => [MyClass, Object, Kernel]

 








Related examples in the same category

1.Look at an object's ancestors with Module's ancestors method, which returns a list of both classes and modules