Another question about Rational#power!. I tried this
NoMethodError: undefined method `power!’ for 2:Fixnum
irb(main):002:0> require ‘rational’
=> 0.25 # huh?
That returns 0.25. However, I would have expected Rational(1, 4).
the code in rational, it looks like power! is an alias for **, and ** is
alias for rpower. So, based on the rpower method, I would think that a
negative value for +other+ would call Rational.new! and return a
Or do I have it wrong?
If Rational is defined, returns a Rational number instead of a
Rational.new!(self,1) / other
alias rdiv quo
Returns a Rational number if the result is in fact rational (i.e.
def rpower (other)
if other >= 0
unless defined? 1.power!
alias power! **
alias ** rpower