[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ruby-talk
Subject:    Re: Probems extending Array
From:       Dave Thomas <dave () pragprog ! com>
Date:       2002-12-31 18:50:18
[Download RAW message or body]

On Tue, 2002-12-31 at 11:51, David Landrith wrote:
> I'm having two problems extending the array class.
> 
> First, I am getting instances where super == nil. 

Super isn't a pointer to the parent class's implementation: it's a call
to the method you're in, but in the partent class.

  class A
    def fred(name)
       puts "hello #{name}"
    end
  end

  class B < A
    def fred(name)
       super("walter")
       super               # calls it with current params
    end
  end

  b = B.new
  b.fred("dave")

     =>  hello walter
         hello dave

         
Cheers


Dave


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic