Hot to call to any parent class method?

Hi, I’ve modified “delete” class in MyArray class but in other custom
method I need to call to iriginal “delete” method.
Well I know that I can do:

alias original_delete delete

def delete(v)
…my_stuff…
end

def other_method

original_delete …
end

end

But, could I do the same without using an alias? could I call directly
to a parent (Array) method from any mehtod of the “soon” class?

I’ve found this way…

class ClassA
def method1
puts “From classA”
end
end

class ClassB < ClassA
def method1
puts “From classB”
end

def method2
    self.class.superclass.instance_method(:method1).bind(self).call
end

end

ClassB.new.method2

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs