From: Stefan Mueller Date: 2002-04-30T01:21:57+09:00 Subject: alias_method problem Hello I hope somebody could tell me, what's wrong with these examples. I just can't find the solution. The following does not work: ----------> module Mod # undefined method `foo' for module `Mod' (NameError) alias_method :origFoo, :foo def foo(code=0) puts "foo code #{code}" origFoo(code) end end class Foo def foo(code=0) puts code end end class Foo include Mod end f = Foo.new f.foo(1) # => "foo code 1", I wish <---- The following (pickaxe:348) does work, but not the way I would like it to, just like the pickaxe original. --------> module Mod alias_method :origExit, :exit def exit(code=0) puts "exit code #{code}" origExit(code) end end class Foo def exit(code=0) puts code end end class Foo include Mod end f = Foo.new f.exit(1) # => 1, but I want "exit code 1" <--------- I don't understand, why "exit" works, and "foo" not. Doing the following does not show "exit" irb> module Mod irb> puts methods irb> end