Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardRubysingleton eigenclassSingle-choice MCQ

Class methods defined with `def self.bar` appear in `Foo.singleton_class.instance_methods(false)`, and a subclass `Sub` inherits `bar`. The chain `Sub.singleton_class.ancestors.first(4)` is shown. What does this reveal about how class methods are inherited?

class Foo def self.bar; :bar; end end class Sub < Foo; end Sub.bar # => :bar Sub.singleton_class.ancestors.first(4) # => [#<Class:Sub>, #<Class:Foo>, #<Class:Object>, #<Class:BasicObject>]