Created
November 17, 2009 23:09
-
-
Save zerowidth/237366 to your computer and use it in GitHub Desktop.
ancestry in ruby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ irb | |
>> module A; end | |
=> nil | |
>> module B; end | |
=> nil | |
>> module C; end | |
=> nil | |
>> module B; include A; end | |
=> B | |
>> class X; include B; end | |
=> X | |
>> module A | |
>> include C | |
>> end | |
=> A | |
>> X.ancestors | |
=> [X, B, A, Object, Wirble::Shortcuts, PP::ObjectMixin, Kernel] | |
>> B.ancestors | |
=> [B, A] | |
>> A.ancestors | |
=> [A, C] | |
>> # note that B does not know about C, even though A does! | |
See also: http://gist.github.com/237387 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment