Hi --

On Thu, 24 Aug 2006, Nathan Smith wrote:

> On Thu, 24 Aug 2006, Douglas A. Seifert wrote:
>
>> Why would you need to explicitly reference super?  It is not necessary:
>>
>> $ irb
>> irb(main):001:0> class Parent
>> irb(main):002:1>   def zoo
>> irb(main):003:2>      puts "zoo in Parent!"
>> irb(main):004:2>   end
>> irb(main):005:1> end
>> => nil
>> irb(main):006:0>
>> irb(main):007:0* class Child < Parent
>> irb(main):008:1>   def hoo
>> irb(main):009:2>      zoo
>> irb(main):010:2>   end
>> irb(main):011:1> end
>> => nil
>> irb(main):013:0> c = Child.new
>> => #<Child:0x39dd78>
>> irb(main):014:0> c.hoo
>> zoo in Parent!
>> => nil
>> irb(main):015:0>
>
> Better example:
>
> class Child < Parent
>  def hoo
>    super.zoo
>  end
>  def zoo
>    print "don't want to be here"
>  end
> end

But the Parent class has no hoo instance method, so calling super from
hoo won't work.


David

-- 
http://www.rubypowerandlight.com => Ruby/Rails training & consultancy
   ----> SEE SPECIAL DEAL FOR RUBY/RAILS USERS GROUPS! <-----
http://dablog.rubypal.com        => D[avid ]A[. ]B[lack's][ Web]log
http://www.manning.com/black     => book, Ruby for Rails
http://www.rubycentral.org       => Ruby Central, Inc.