isn't this easier?

class Fixnum
  def power(exp)
    self ** exp
  end
end

a=10
a.power 2

    robert

"Joel VanderWerf" <vjoel / PATH.Berkeley.EDU> schrieb im Newsbeitrag
news:3E723D76.9090807 / path.berkeley.edu...
> Rudolf Polzer wrote:
> > But I'd still like to know how to dynamically create a method with
a
> > dynamically given name. If possible, without such a hackery.
>
> irb(main):003:0> Fixnum.instance_eval {define_method(:power) do |a|
self
> ** a end}
> #<Proc:0x40210220@(irb):3>
> irb(main):004:0> 3.power 2
> 9
>
> The instance_eval is because it's a private method.
>
>