From: Jason Roelofs Date: 2008-12-30T17:53:49+09:00 Subject: [ruby-core:20989] Re: Re: Re: Re: Definable != is a Bad Thing™ 2008/12/30 Rados�aw Bu�at : > On Tue, Dec 30, 2008 at 2:31 AM, Ryan Davis wrote: >> >> ok... but why? > > Because it's Ruby. > > $ cat horrible.rb > puts 1 + 1 > > class Fixnum > def +(o) > :horrible > end > end > > puts 1 + 1 > $ ruby horrible.rb > 2 > horrible > > > Btw, I wonder if it's a bug or not: > $ cat horrible.rb > class Fixnum > def -@ > :horrible > end > end > > puts -1 > puts -(1) > > $ ruby horrible.rb > -1 > horrible > > > -- > Pozdrawiam > > Rados�aw Bu�at > http://radarek.jogger.pl - m�j blog > Not a bug, but how the parser handles numbers. -1 is read as "negative 1" while -(1) is "call 1.-()." Now if you did x = 1 puts -x I do believe you'd get :horrible, but don't have a console to test this out right now. As for the OP, this is *the* most powerful feature of Ruby and frankly it's what makes Ruby, well, Ruby. You can redefine any message to do whatever you want, and it's up to you to not be dumb about it. Jason