Is there a way (or Ruby way?) to get the reference to the super instance of an object? I need the reference as the starting point in a recursive call, so simply using alias_method (as suggested by previous post) will not work around the problem. Thank you very much!
Is there a way (or Ruby way?) to get the reference to the super
instance of an object? I need the reference as the starting point in
a recursive call, so simply using alias_method (as suggested by
previous post) will not work around the problem. Thank you very much!
What do you mean by "super instance"? Ruby is not C++ - you cannot (and need not) cast a reference to another type simply because references are typeless.
If you just want to call the implementation of a method in the super class, simply use super:
class Base
def foo() puts "base" end
end
class Derived < Base
def foo() super; puts "derived" end
end