From: eregontp@... Date: 2020-09-25T10:22:09+00:00 Subject: [ruby-core:100135] [Ruby master Feature#14394] Class.descendants Issue #14394 has been updated by Eregon (Benoit Daloze). byroot (Jean Boussier) wrote in #note-16: > > self should be is contained or not? > > I don't think it should no. `self < self # => self`. `Module#ancestors` includes `self`. `#descendants` is kind of the opposite/complement of `mod.ancestors` (finds all modules for which `mod` is in the `ancestors`, excluding singleton classes). So it seems OK to me it does not include `self`. > As long as it has reasonable performance I expect Object.descendants to be quite slow, so it depends on how many descendants there are (including singleton classes which might be tracked internally). Also we probably need to avoid recursion for modules as I think it's not a DAG there. ---------------------------------------- Feature #14394: Class.descendants https://bugs.ruby-lang.org/issues/14394#change-87706 * Author: ridiculous (Ryan Buckley) * Status: Feedback * Priority: Normal ---------------------------------------- There have been numerous implementations of the method Class.descendants by various gems. However, I can't help but think that this ability should be included in the Ruby language itself. Especially since Ruby already offers the counterpart method Class.ancestors. Would it possible to add a `descendants` class method? -- https://bugs.ruby-lang.org/ Unsubscribe: