# Super.index gives error

**URL:** <https://www.ruby-forum.com/t/super-index-gives-error/129535>\
**Category:** Ruby\
**Created:** [February 19, 2008, 11:35am UTC](https://www.ruby-forum.com/t/super-index-gives-error/129535 "2008-02-19T11:35:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![MohsinHijazee](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e68b1a/32.png) [@MohsinHijazee](https://www.ruby-forum.com/u/MohsinHijazee)\
**Post date:** [February 19, 2008, 11:35am UTC](https://www.ruby-forum.com/t/super-index-gives-error/129535/1 "2008-02-19T11:35:47Z")

</div>

Hello!  
I’m having a strange problem.

class Super

def index  
puts “some code”  
end  
end

class Base \< Super

def index  
super.index() # Says you super is nil! nil.index and an  
error. What might be wrong?  
end  
end

---

<div class="post-metadata">

**Author:** ![MohsinHijazee](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e68b1a/32.png) [@MohsinHijazee](https://www.ruby-forum.com/u/MohsinHijazee)\
**Post date:** [February 19, 2008, 11:39am UTC](https://www.ruby-forum.com/t/super-index-gives-error/129535/2 "2008-02-19T11:39:20Z")

</div>

Hi:

On Feb 19, 2008 9:34 PM, MohsinHijazee [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> class Base \< Super
> 
> def index  
> super.index() # Says you super is nil! nil.index and an  
> error. What might be wrong?  
> end  
> end

irb(main):001:0\> class Super  
irb(main):002:1\> def index  
irb(main):003:2\> puts “some code”  
irb(main):004:2\> end  
irb(main):005:1\> end  
=\> nil  
irb(main):006:0\> class Sub \< Super  
irb(main):007:1\> def index  
irb(main):008:2\> super  
irb(main):009:2\> end  
irb(main):010:1\> end  
=\> nil  
irb(main):011:0\> Sub.new.index  
some code  
=\> nil  
irb(main):012:0\>

Technically, Super is also the `base' class, so I named it Sub. Just use `super’ – super calls the method of the same name in the superclass.

HTH  
Arlen

---

<div class="post-metadata">

**Author:** ![MohsinHijazee](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e68b1a/32.png) [@MohsinHijazee](https://www.ruby-forum.com/u/MohsinHijazee)\
**Post date:** [February 19, 2008, 11:51am UTC](https://www.ruby-forum.com/t/super-index-gives-error/129535/3 "2008-02-19T11:51:11Z")

</div>

On Feb 19, 3:38 pm, Arlen C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > ```
> > super.index() # Says you super is nil! nil.index and an
> > 
> > ```
> 
> irb(main):006:0\> class Sub \< Super  
> Technically, Super is also the `base' class, so I named it Sub. Just use `super’ – super calls the method of the same name in the superclass.
> 
> HTH  
> Arlen

Thank you very much! The problem is solved
