Issue #14394 has been updated by marcandre (Marc-Andre Lafortune).


+1 for this feature from me.

@hanmac: if you are referring to singleton classes, they should be excluded:

```
s = +'hello'
def s.force_singleton_class
  42
end
s.singleton_class < String # => true
String.descendants.include?(s.singleton_class) # => should be false
```

Note that the base class' `inherited` method is not called when a singleton class is created.

If not, I agree with @eregon, no extra filter necessary.

----------------------------------------
Feature #14394: Class.descendants
https://bugs.ruby-lang.org/issues/14394#change-87320

* Author: ridiculous (Ryan Buckley)
* Status: Open
* 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: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>