H
has
Wondering if the following behaviour is a bug or a feature:
#######
module Foo
class Bar
end
def baz
end
end
o = Foo::Bar.new
p respond_to?baz) # false
p o.respond_to?baz) # false
include Foo
o = Bar.new
p respond_to?baz) # true
p o.respond_to?baz) # true <------ shouldn't this be false?
#######
'include Foo' adds Bar and baz to the top-level namespace as expected.
What I don't understand is why baz should also appear as a method of
Bar. Anyone know what's going on here?
Thanks,
has
#######
module Foo
class Bar
end
def baz
end
end
o = Foo::Bar.new
p respond_to?baz) # false
p o.respond_to?baz) # false
include Foo
o = Bar.new
p respond_to?baz) # true
p o.respond_to?baz) # true <------ shouldn't this be false?
#######
'include Foo' adds Bar and baz to the top-level namespace as expected.
What I don't understand is why baz should also appear as a method of
Bar. Anyone know what's going on here?
Thanks,
has