# "super" bug

**URL:** <https://www.ruby-forum.com/t/super-bug/85401>\
**Category:** Ruby\
**Created:** [February 13, 2007, 7:19am UTC](https://www.ruby-forum.com/t/super-bug/85401 "2007-02-13T07:19:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ledelste](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/85f322/32.png) [@ledelste](https://www.ruby-forum.com/u/ledelste)\
**Post date:** [February 13, 2007, 7:19am UTC](https://www.ruby-forum.com/t/super-bug/85401/1 "2007-02-13T07:19:37Z")

</div>

Hi all -

I misused the “super” keyword and I think I should have received an  
error, but didn’t.

I tried “super.my\_method\_name(…)” and got strange results. OK, fine,  
I’m supposed to say “super(…)” or just “super”. But shouldn’t I get a  
compilation error or something? Is the behavior of  
“super.my\_method\_name(…)” even defined?

-larry

---

<div class="post-metadata">

**Author:** ![ledelste](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/85f322/32.png) [@ledelste](https://www.ruby-forum.com/u/ledelste)\
**Post date:** [February 13, 2007, 7:29am UTC](https://www.ruby-forum.com/t/super-bug/85401/2 "2007-02-13T07:29:18Z")

</div>

On Tue, 13 Feb 2007, Larry Edelstein wrote:

> Hi all -
> 
> I misused the “super” keyword and I think I should have received an  
> error, but didn’t.
> 
> I tried “super.my\_method\_name(…)” and got strange results. OK, fine,  
> I’m supposed to say “super(…)” or just “super”. But shouldn’t I get a  
> compilation error or something? Is the behavior of  
> “super.my\_method\_name(…)” even defined?

sure it is

( the\_object\_returned = super ).my\_method\_name( 42 )

‘super’ in ruby is not an object - it defers to the method of the same  
name in  
the parent class and returns whatever that does.

regards.

-a

---

<div class="post-metadata">

**Author:** ![ledelste](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/85f322/32.png) [@ledelste](https://www.ruby-forum.com/u/ledelste)\
**Post date:** [February 13, 2007, 8:54am UTC](https://www.ruby-forum.com/t/super-bug/85401/3 "2007-02-13T08:54:08Z")

</div>

Larry Edelstein wrote:

> Hi all -
> 
> I misused the “super” keyword and I think I should have received an  
> error, but didn’t.
> 
> I tried “super.my\_method\_name(…)” and got strange results. OK, fine,  
> I’m supposed to say “super(…)” or just “super”. But shouldn’t I get a  
> compilation error or something? Is the behavior of  
> “super.my\_method\_name(…)” even defined?
> 
> -larry

as “a” already pointed out, super is a method call. I’d like to add,  
that super and super() differ, super without parens calls the same  
method in the parent class with all parameters passed to the current  
method.

my regards

---

<div class="post-metadata">

**Author:** ![ledelste](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/85f322/32.png) [@ledelste](https://www.ruby-forum.com/u/ledelste)\
**Post date:** [February 13, 2007, 9:00am UTC](https://www.ruby-forum.com/t/super-bug/85401/4 "2007-02-13T09:00:22Z")

</div>

unknown wrote:

Ah, right…it invokes the specified method on whatever happens to be  
returned by the call to the superclass’s method.

It’s the downside of weakly typed languages - they make it easy to get  
an oddball result like this. (Of course not knowing how to actually use  
the language helps, too, heh heh.)

-larry

> On Tue, 13 Feb 2007, Larry Edelstein wrote:
> 
> > Hi all -
> > 
> > I misused the “super” keyword and I think I should have received an  
> > error, but didn’t.
> > 
> > I tried “super.my\_method\_name(…)” and got strange results. OK, fine,  
> > I’m supposed to say “super(…)” or just “super”. But shouldn’t I get a  
> > compilation error or something? Is the behavior of  
> > “super.my\_method\_name(…)” even defined?
> 
> sure it is
> 
> ( the\_object\_returned = super ).my\_method\_name( 42 )
> 
> ‘super’ in ruby is not an object - it defers to the method of the same  
> name in  
> the parent class and returns whatever that does.
> 
> regards.
> 
> -a
