singleton class should be included in ancestors
I feel it would be consistent if:
k.ancestors.include?(k) #=> always true if k.is_a?(Class)
This is currently the case except for singleton classes:
class << ""; include Enumerable; end.ancestors # => [Enumerable, String, Comparable, Object, Kernel, BasicObject] # would be more consistent: # => [#<Class:#<String:0x0000010113d268>>, Enumerable, String, Comparable, Object, Kernel, BasicObject]
Note that the singleton classes do appear in the ancestors if a module is instead prepended:
class << ""; prepend Enumerable; end.ancestors # => [Enumerable, #<Class:#<String:0x0000010113d268>>, String, Comparable, Object, Kernel, BasicObject]
Updated by alexeymuranov (Alexey Muranov) over 10 years ago
Singleton class it the same thing as metaclass, right? I feel it would be better to keep it invisible, and maybe in the future to remove it completely and to allow objects to keep their singleton methods themselves.
Updated by marcandre (Marc-Andre Lafortune) over 10 years ago
- Status changed from Open to Closed
- % Done changed from 0 to 100
This issue was solved with changeset r39628.
Marc-Andre, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
class.c (rb_mod_ancestors): Include singleton_class in ancestors list
test/ruby/test_module.rb (class): test for above
test/ruby/marshaltestlib.rb (module): adapt test
NEWS: list change