I am having some confusion with the include
method in Ruby, to include
a module in a parent class, which is defined in a child class of that
parent class.
class B
module M
def meth
11
end
end
end
class A < B
end
A.new.meth # undefined method `meth’ for #<A:0x9780bdc> (NoMethodError)
I am fine with above.
class B
module M
def meth
11
end
end
end
class A < B
include M
end
A.new.meth # => 11
still I am fine with this.
Why I am not able to do the below?
class A
include B::M
end
class B < A
module M
def meth
11
end
end
end