Hello,
I was recently surprised to find that I can’t do:
class Outer
def method_missing(methID, *args, &block)
p methID.id2name
end
end
class Inner < Outer
def foo
super
end
end
obj = Inner.new
obj.foo
It raises: “super: no superclass method `foo’ (NameError)”
Is this behavior intentional? Why should super() assume that we won’t
catch the undefined method with method_missing? If this isn’t a bug, is
there another way to accomlish this same thing - namely, to have a
top-level class which filters all undefined methods and have subclasses
which sometimes overload those methods but still may need to pass the
method on to the superclass?
Thanks,
-Brad
stranger still that this does work :
class Outer
def method_missing(methID, *args, &block)
p methID.id2name
end
end
class Inner < Outer
def foo
super
end
end
o = Outer.new
o.foo
obj = Inner.new
obj.foo
-a
···
On Sat, 8 Feb 2003, Brad Hilton wrote:
Hello,
I was recently surprised to find that I can’t do:
class Outer
def method_missing(methID, *args, &block)
p methID.id2name
end
end
class Inner < Outer
def foo
super
end
end
obj = Inner.new
obj.foo
It raises: “super: no superclass method `foo’ (NameError)”
–
====================================
Ara Howard
NOAA Forecast Systems Laboratory
Information and Technology Services
Data Systems Group
R/FST 325 Broadway
Boulder, CO 80305-3328
Email: ahoward@fsl.noaa.gov
Phone: 303-497-7238
Fax: 303-497-7259
====================================