How do I call a super class method
Posted
by KandadaBoggu
on Stack Overflow
See other posts from Stack Overflow
or by KandadaBoggu
Published on 2010-04-02T00:06:41Z
Indexed on
2010/04/02
0:13 UTC
Read the original article
Hit count: 709
ruby
I have two classes A, and B. Class B overrides the foo method of class A. Class B has a bar method where I want to call the foo method of the super class. What is the syntax for such a call?
class A
def foo
"hello"
end
end
class B
def foo
super + " world"
end
def bar
# how to call the `foo` method of the super class?
# something similar to
super.foo
end
end
© Stack Overflow or respective owner