Alias_method problem

Thanks. Using “method_defined?” worked around the problem.

···

From POP3 Tue Jul 16 16:22:52 EDT 2002
Date: Wed, 17 Jul 2002 05:22:16 +0900
Posted: Tue, 16 Jul 2002 15:28:01 -0500
From: “Hal E. Fulton” hal9000@hypermetrics.com
Subject: Re: alias_method problem
To: ruby-talk@ruby-lang.org (ruby-talk ML)
X-ML-Name: ruby-talk
X-Mail-Count: 44656
X-MLServer: fml [fml 3.0pl#17]; post only (anyone can post)
X-ML-Info: If you have a question, send e-mail with the body
"help" (without quotes) to the address ruby-talk-ctl@ruby-lang.org;
help=mailto:ruby-talk-ctl@ruby-lang.org?body=help
X-Priority: 3
X-MSMail-Priority: Normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
Mime-Version: 1.0
Content-Transfer-Encoding: 7bit

----- Original Message -----
From: “Steve Tuckner” STUCKNER@MULTITECH.COM
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Sent: Tuesday, July 16, 2002 3:09 PM
Subject: RE: alias_method problem

I too have run in to this and implemented an ugly kludge to deal with it
(instead of taking the time to figure it out).

class A
$aliased = $aliased || 0

if $aliased == 0 then
# method “newone” is defined in a different file.
alias_method :oldone, :newone
def newone
oldone
end
end
$aliased += 1
end

Hmmmm… I haven’t tested this, but here’s a
thought:

Could you test the value of "defined? oldone"
rather than resorting to a global variable?
Still a kludge, but maybe less so…

Hal