Hello,
I’m trying to overload Fixnum#+, but I am getting what seems to be a
recursion (see below). Does anyone know what that happens? Perhaps I
don’t know how “alias” works.
$ cat >test.rb
class Fixnum
alias plus +
def +(other)
puts “hello”
self.plus(other)
end
end
$ irb
require ‘test’
=> true
2+2
hello
hello
hello
hello
hello
hello
hello
hello
hello
hello
hello
hello
hello
hello
hello
hello
hello
hello
hello
hello
hello
=> 4
···
–
Daniel Carrera
Graduate Teaching Assistant. Math Dept.
University of Maryland. (301) 405-5137