B
Barbara Mcinnes
Hi there,
Hoping someone explain this to me as I'd like to understand it properly.
I've been reading about Ruby's metaclasses, but I don't get this:
class Test
def foo
puts "in foo"
end
end
=> nil
class Test2 < Test
def self.bar
foo
end
def method_missing(name, *args)
puts "in method_missing"
end
end
=> nil
=> nil
=> nil
why does invoking method bar on the instance find class Test2's
method_missing instance method, but not instance method foo inherited
from class Test?
Thanks for any help!
Hoping someone explain this to me as I'd like to understand it properly.
I've been reading about Ruby's metaclasses, but I don't get this:
class Test
def foo
puts "in foo"
end
end
=> nil
class Test2 < Test
def self.bar
foo
end
def method_missing(name, *args)
puts "in method_missing"
end
end
=> nil
in method_missingTest2.new.bar
=> nil
in fooTest2.new.foo
=> nil
why does invoking method bar on the instance find class Test2's
method_missing instance method, but not instance method foo inherited
from class Test?
Thanks for any help!