From: Eric Mahurin Date: 2005-10-26T04:33:28+09:00 Subject: Re: Redefine minus unary method Fixnum overrode -@ but not +@. Redefining the superclass method doesn't do any good if you are using the sub-classes and they overrode the methods. You need to redefine Fixnum#-@ and Bignum#-@ if you want to do this. Be warned though - redefining core class methods can result in inconsistent behavior because some places may bypass the normal method call mechanism or not use the methods you expect. I think it best not to redefine core class methods or sub-class core classes. You are just asking for trouble when you do that. --- David Tran wrote: > class Integer > def +@ > super > puts 'redefine + unary' > self > end > > def -@ > super > puts 'redefine - unary' > self > end > end > > +(2) # print out 'redefine + unary' > -(2) # nothing print out, why ? > > a = 4 > a = +a # print out 'redefine + unary' > a = -a # nothing print out, why ? > > __________________________________ Yahoo! FareChase: Search multiple travel sites in one click. http://farechase.yahoo.com