From: Mark Hubbart Date: 2005-10-20T07:42:15+09:00 Subject: Re: Integer#** weirdness On 10/19/05, Joe Mason wrote: > On Wed, Oct 19, 2005 at 07:19:12PM +0900, Peter Vanbroekhoven wrote: > > I was aware where the error was generated (even looked at the code), but I > > didn't realize that it was not supposed to be loaded without being > > required explicitly. Actually I'm not requiring it, Rubygems is (it > > requires time.rb, which indirectly requires rational.rb). But turning off > > Rubygems is not an option, so it would be nice if rational.rb was changed > > per your suggestion above. > > For now, you could reopen Rational in your class to add a wrapper to rpower. With the copious aliases (alii?) that are in that area, I didn't at first think it would be so easy. But it only took one alias_method to fix it. You could: require 'rational' class Fixnum def rpower (other) me, you = other.coerce(self) return me**you unless me == self if other >= 0 self.power!(other) else Rational.new!(self,1)**other end end alias_method :**, :rpower end This is a more compatible than the solution using #is_a?, since it will allow a number to convert itself to an integer if possible, instead of relying on a fixed class choice. cheers, Mark