mirror of
https://github.com/jbranchaud/til
synced 2026-01-07 09:08:01 +00:00
Add Who Are My Ancestors as a ruby til.
This commit is contained in:
@@ -218,6 +218,7 @@ smart people at [Hashrocket](http://hashrocket.com/).
|
|||||||
- [Summing Collections](ruby/summing-collections.md)
|
- [Summing Collections](ruby/summing-collections.md)
|
||||||
- [Uncaught Exceptions In Pry](ruby/uncaught-exceptions-in-pry.md)
|
- [Uncaught Exceptions In Pry](ruby/uncaught-exceptions-in-pry.md)
|
||||||
- [`undef_method` And The Inheritance Hierarchy](ruby/undef-method-and-the-inheritance-hierarchy.md)
|
- [`undef_method` And The Inheritance Hierarchy](ruby/undef-method-and-the-inheritance-hierarchy.md)
|
||||||
|
- [Who Are My Ancestors?](ruby/who-are-my-ancestors.md)
|
||||||
- [Zero Padding](ruby/zero-padding.md)
|
- [Zero Padding](ruby/zero-padding.md)
|
||||||
|
|
||||||
### tmux
|
### tmux
|
||||||
|
|||||||
17
ruby/who-are-my-ancestors.md
Normal file
17
ruby/who-are-my-ancestors.md
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
# Who Are My Ancestors?
|
||||||
|
|
||||||
|
Ruby's `Module` class provides the
|
||||||
|
[`#ancestors`](http://ruby-doc.org/core-2.1.0/Module.html#method-i-ancestors)
|
||||||
|
method. This method allows you to determine the ancestors (parents,
|
||||||
|
grandparents, etc.) of a given class.
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
> 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]
|
||||||
|
```
|
||||||
Reference in New Issue
Block a user