From: nobu.nokada@... Date: 2003-02-08T13:01:26+09:00 Subject: Re: help overloading operators Hi, At Sat, 8 Feb 2003 09:55:23 +0900, Daniel Carrera wrote: > 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? I can't reproduce your error. $ ruby -rcomplex -rpoly -e 'p 2+Complex(1,1)' Complex(3, 1) $ ruby -rcomplex -rpoly -e 'p 2.0+Complex(1,1)' ./poly.rb:4:in `+': undefined local variable or method `poly' for 2.0:Float (NameError) from -e:1 Apparently, something wrong is in the remain of your code. -- Nobu Nakada