Skip to content

Instantly share code, notes, and snippets.

@zerowidth
Created November 17, 2009 23:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zerowidth/237366 to your computer and use it in GitHub Desktop.
Save zerowidth/237366 to your computer and use it in GitHub Desktop.
ancestry in ruby
$ 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