From: HarryO Date: 2001-11-16T22:27:18+09:00 Subject: [ruby-talk:25422] Re: Redefining Fixnum.x(val)? In article <002501c16e99$125cae40$6329c6c3@telia.com>, "Henning von Rosen" wrote: > It works just fine, the first time I run it. If it is run a second time, > in the same interpreter, then the old and new plus gets identical, and > the result is an infinte loop. When running the script from the command > line, there should be no problem. The problem is that the second time, Fixnum#+() is already your new definition, so when you create the alias it's aliasing to the same method. In practice, this would not happen, except that you are re-running the same code inside the same interpreter, as you say. You can avoid the problem by adding a test around the alias creation, like this ... if !defined? oldPlus alias oldAlias + end > What do you use for running the program? I put the code in a file, say "fred.rb" then run the command "ruby fred.rb". In this case, each time I run the code it's in a new copy of the interpreter, so this kind of problem doesn't occur. Hope that helps.