1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-03 07:08:01 +00:00
Files
til/ruby/who-are-my-ancestors.md
2015-12-31 10:59:25 -06:00

576 B

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]