Issue #18273 has been updated by zverok (Victor Shepelev). @fxn You know what? I think I actually got your point: * `Class#ancestors` represent a "really existing thing", that is, objective ancestors chain. E.g. it is an API to an internal _structures_, helping to make sense of them; * `Class#subclasses` look the same way, therefore implying it is also an API to internally existing structures (for example, to each class keeping track of its descendants because it is a part of an object model)¡½but this implication is completely untrue! The `#subclasses` is a dynamic thing¡½and in more formal language, maybe should've at least been called `#enumerate_subclasses` (implying by a verb form that it will _do_ something, not just expose internally existing reality) Is that it? ---------------------------------------- Feature #18273: Class#subclasses https://bugs.ruby-lang.org/issues/18273#change-96125 * Author: byroot (Jean Boussier) * Status: Closed * Priority: Normal ---------------------------------------- Ref: https://github.com/rails/rails/pull/43481 Something we forgot to mention in [Feature #14394], is either a parameter or another method to only get direct descendants. Active Support has been offering `Class.subclasses` as: ```ruby def subclasses descendants.select { |descendant| descendant.superclass == self } end ``` It seems a bit silly to grab all descendants and then restrict the list when `Class#descendants` had to do some recursion to get them all in the first place. ### Proposal We could either implement `Class#subclasses` directly, or accept a parameter in `Class#descendants`, e.g. `descendants(immediate = false)`. cc @eregon -- https://bugs.ruby-lang.org/ Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>