Skip to content

Latest commit

 

History

History
17 lines (15 loc) · 576 Bytes

who-are-my-ancestors.md

File metadata and controls

17 lines (15 loc) · 576 Bytes

Who Are My Ancestors?

Ruby's Module class provides the #ancestors method. This method allows you to determine the ancestors (parents, grandparents, etc.) of a given class.

> 5.class.ancestors
=> [Fixnum, Integer, Numeric, Comparable, Object, PP::ObjectMixin, Kernel, BasicObject]
> Array.ancestors
=> [Array, Enumerable, Object, PP::ObjectMixin, Kernel, BasicObject]
> Class.ancestors
=> [Class, Module, Object, PP::ObjectMixin, Kernel, BasicObject]
> BasicObject.ancestors
=> [BasicObject]