# How can I invoke super class's method

**URL:** <https://www.ruby-forum.com/t/how-can-i-invoke-super-classs-method/147300>\
**Category:** Ruby\
**Created:** [August 30, 2008, 5:41pm UTC](https://www.ruby-forum.com/t/how-can-i-invoke-super-classs-method/147300 "2008-08-30T17:41:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![youhaodeyi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/b9bd4f/32.png) [@youhaodeyi](https://www.ruby-forum.com/u/youhaodeyi)\
**Post date:** [August 30, 2008, 5:41pm UTC](https://www.ruby-forum.com/t/how-can-i-invoke-super-classs-method/147300/1 "2008-08-30T17:41:34Z")

</div>

My class include a Module and overwrite a method of the Module. In this  
method, I want to invoke the Module’s method first. Just like  
“super.method()” in Java. How can I do this?

---

<div class="post-metadata">

**Author:** ![youhaodeyi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/b9bd4f/32.png) [@youhaodeyi](https://www.ruby-forum.com/u/youhaodeyi)\
**Post date:** [August 30, 2008, 6:19pm UTC](https://www.ruby-forum.com/t/how-can-i-invoke-super-classs-method/147300/2 "2008-08-30T18:19:42Z")

</div>

Zhao Yi wrote:

> My class include a Module and overwrite a method of the Module. In this  
> method, I want to invoke the Module’s method first. Just like  
> “super.method()” in Java. How can I do this?

Just the word super().  
module M  
def q(arg)  
#  
end  
end  
class K  
include M  
def q(arg)  
#  
super(arg)  
end  
end

super() calls ancestor’s function with the same name as the function  
you’re currently in.

TPR.

---

<div class="post-metadata">

**Author:** ![youhaodeyi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/b9bd4f/32.png) [@youhaodeyi](https://www.ruby-forum.com/u/youhaodeyi)\
**Post date:** [August 30, 2008, 8:30pm UTC](https://www.ruby-forum.com/t/how-can-i-invoke-super-classs-method/147300/3 "2008-08-30T20:30:36Z")

</div>

Hi –

On Sun, 31 Aug 2008, Thomas B. wrote:

> end  
> class K  
> include M  
> def q(arg)
> 
> # 
> 
> super(arg)  
> end  
> end
> 
> super() calls ancestor’s function with the same name as the function  
> you’re currently in.

Keep in mind, though, that the semantics of super (which is a keyword,  
rather than a method) are a bit different from regular method-calling  
semantics:

super # call ancestor’s method with current arguments  
super(a,b) # call with exactly the arguments (a,b)  
super() # call with no arguments

It’s really the first one that’s the special case, as you can see.

David

---

<div class="post-metadata">

**Author:** ![youhaodeyi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/b9bd4f/32.png) [@youhaodeyi](https://www.ruby-forum.com/u/youhaodeyi)\
**Post date:** [August 31, 2008, 4:42am UTC](https://www.ruby-forum.com/t/how-can-i-invoke-super-classs-method/147300/4 "2008-08-31T04:42:26Z")

</div>

Got it thanks.
