Warning: discarding old <methodName>?

Hmm sounds quite like I thought but I donot see the point.

May it come indirectly through require statements like:

  • module M requires a.rb and b.rb
  • both, a and b require c.rb

I’ll have to examine tomorrow, for today it’s enough :wink:

I use stable 1.6.7 on win32

Best wishes
Juergen Lind

···

-----Original Message-----
From: dblack@candle.superlink.net [mailto:dblack@candle.superlink.net]
Sent: Wednesday, December 11, 2002 6:14 PM
To: ruby-talk@ruby-lang.org
Subject: Re: warning: discarding old ?

Hi –

On Thu, 12 Dec 2002, Lind, Juergen wrote:

Hi folks,

why does this warning come up?
What might be wrong with my code?

The warning (“discarding old ”) comes up when you discard an
old method :slight_smile:

It basically means that you’ve overridden a method without saving
a path to the old version of the method.

For example:

class String
def split; end
end

However, if you do this:

class String
alias :oldsplit :split
def split; end
end

the old method is still available (as oldsplit), so it has not
been discarded and there’s no warning.

David


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