Reputation: 4895
Good day, i'm new to ruby. I want to know how to run a parent method from a method of a child class ? in java it would be like
class Child
..
def something_else
super.something
end
end
and in php
parent::method_name();
And could you tell me how to do it in Ruby? found only this, and it's kind of ugly using alias_method_chain
Upvotes: 3
Views: 1871
Reputation: 4895
as Taiki suggested the comment in another thread stated
class B < A
alias :super_a :a
def a
b()
end
def b
super_a()
end
end
hope there are other ways...
UPDATE:
at long last, call super() instead of super_a(). not sure what it does completely though
Upvotes: 2