Hello --


On Fri, 7 Sep 2001, Piers Cawley wrote:

> Henry House <hajhouse / houseag.com> writes:
[...]
> >
> > ...but I don't how (if it is possible?) to call the original to_i. Am I stuck
> > with using a new method name or a custom string class?
>
> Frankly I'd hope that 'super' would do the job, but it seems from the
> rest of the thread that it doesn't...


super takes you back up the class hierarchy, which isn't the same thing as
overriding/aliasing a method within a single class.  Those two things have
something in common, in that they both involve getting at a method with
the same name as the current method, but beyond that they're really
orthogonal operations.

For example:

  class A
    def thing
      puts "hi"
    end
  end

  class B < A
  end

  class B
    def thing
      puts "I'd like to say..."
      super
    end
  end

  class B
    alias :other :thing
    def thing
      puts "I used to say"
      super
      puts "then I started saying"
      other
    end
  end


David

-- 
David Alan Black
home: dblack / candle.superlink.net
work: blackdav / shu.edu
Web:  http://pirate.shu.edu/~blackdav