From: Daniel Carrera Date: 2003-02-08T09:55:23+09:00 Subject: help overloading operators I'm trying to overload Float#+, but I'm doing it wrong and it's breaking Float#+. For example: >> require 'complex' => true >> 2 + Complex(1,1) # -> works fine => Complex(3, 1) >> require 'poly' # -> breaks Float#+ => true >> 2 + Complex(1,1) # -> broken NoMethodError: undefined method `plus' for # from ./poly.rb:216:in `plus' from ./poly.rb:216:in `+' from (irb):4 from :0 >> This is the code I'm using: class Float alias plus + def +(other) other.kind_of?(poly) ? other.+(self) : self.plus(other) end end I don't understand the error. I defnined "plus" for Float, not for Complex. Does anyone know how I should be overloading this operator? Thanks a lot. -- Daniel Carrera Graduate Teaching Assistant. Math Dept. University of Maryland. (301) 405-5137