From: Hiroshi Nakamura Date: 2012-03-18T14:41:34+09:00 Subject: [ruby-core:43387] [ruby-trunk - Feature #2065] An ancestors iterator Issue #2065 has been updated by Hiroshi Nakamura. Description updated Assignee set to Yusuke Endoh ---------------------------------------- Feature #2065: An ancestors iterator https://bugs.ruby-lang.org/issues/2065#change-24695 Author: Simon Chiang Status: Feedback Priority: Low Assignee: Yusuke Endoh Category: core Target version: 2.0.0 =begin I have implemented DSLs that add features to a class/module that should be inherited like methods. In those cases I end up iterating ancestors to find the first time a feature has been added (the same way I imagine methods are determined). The issue is that SomeClass.ancestors regenerates the ancestors array each time it is called. Therefore this is relatively slow: SomeClass.ancestors.each do |ancestor| # ... end It would be nice if there were a method that iterates ancestors without generating the ancestors array: SomeClass.each_ancestor do |ancestor| # ... end This could improve the performance of DSLs that want to support method-like inheritance. =end -- http://bugs.ruby-lang.org/