Issue #18273 has been updated by zverok (Victor Shepelev). We are going in circles here :( It is "non-deterministic" all right, but also reflects the reality. It is more or less the same as with ```ruby Thread.new {}.run Thread.list ``` ...isn't it? We can't predict what the 2nd line is going to return. Should we argue that `Time.now` value can't be predicted and therefore non-deterministic, and therefore a bad API? (I am not trolling, I am trying to see what lies in the gap between just repeating that it is non-deterministic and therefore not acceptable from one side, and it is how it really is and therefore totally sane API from another.) ---------------------------------------- Feature #18273: Class#subclasses https://bugs.ruby-lang.org/issues/18273#change-96122 * 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>