Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Ruby
Finding parent-class hierarchy recursively
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Sebastian Hungerecker, post: 4618729"] Ok, here's what happens: parents(Class) = (parents(Module) << Class).reverse parents(Module) = (parents(Object) << Module).reverse parents(Object) = [Object] parents(Module) = ([Object] << Module).reverse = [Module, Object] parents(Class) = ([Module, Object] << Class).reverse = [Module, Object, Class].reverse = [Class, Object, Module] Anyway, do you know that you can get what you want just by calling TheClass.ancestors? Well, not quite as that also includes included modules, but TheClass.ancestors.grep(Class) would give you exactly the results you expected from your method. HTH, Sebastian [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Ruby
Finding parent-class hierarchy recursively
Top