From: Phrogz Date: 2007-01-23T08:15:07+09:00 Subject: Re: Minor Change Proposal for Class 'Numeric' Wolfgang N�dasi-Donner wrote: > class Numeric > def sign > self<0?-1:self>0?1:0 > end > end > > ...but it should be much faster if be defined in the original class. a) Why do you need it to be so fast? Two comparisons seems pretty lightweight to me! b) Why do you think it's generally useful? I think such a method would have helped me only once or twice in all my programming years. c) You can implement that more compactly (if not more efficiently) as: irb(main):001:0> class Numeric; def sign; self <=> 0; end; end => nil irb(main):002:0> -1.sign => -1 irb(main):003:0> -5.sign => -1 irb(main):004:0> 0.sign => 0 irb(main):005:0> 3.sign => 1