From: dblack@... Date: 2002-09-29T06:23:10+09:00 Subject: Re: alias versus method_missing Hi -- On Sun, 29 Sep 2002, Joel VanderWerf wrote: > Lyle Johnson wrote: > ... > > understand why. But I was trying to figure out if there's an alternative > > that gets me what I really wanted (sort-of a "virtual alias"). > > It's a little less efficient, but this seems to be virtual: > > class Base > def bar; foo; end > end > > There must be a way to use Class#inherited to good effect, but the > following doesn't seem to work: > > class Base > def self.inherited(sub) > sub.class_eval {alias_method :bar, :foo} > end > end > > Derived.new.bar # ==> inside Base#foo > > However, > > Derived.class_eval {alias_method :bar, :foo} > Derived.new.bar # ==> inside Derived#foo > > Anyone understand why? (I'm using 1.6.7, and maybe this would be > different in a recent 1.7.) I get two #foo's with 1.6.7. David -- David Alan Black | Register for RubyConf 2002! home: dblack@candle.superlink.net | November 1-3 work: blackdav@shu.edu | Seattle, WA, USA Web: http://pirate.shu.edu/~blackdav | http://www.rubyconf.com