>>   rpolzer@katsuragi rpolzer $ irb
>>   irb(main):001:0> Fixnum.instance_eval {define_method(:power) do |a| self ** a end}
>>   => #<Proc:0x4006bf00>
>>   irb(main):002:0> 3.power 2
>>   NameError: undefined method `**' for Fixnum:Class
>>           from (irb):1
>>           from (irb):1:in `power'
>>           from (irb):2
>> 
>> I have Ruby 1.6.8.
>> 
>> Do I need another way to access the "self"?

It is a difference of 1.6 and 1.7 or later, according to ja/man-1.6
http://www.ruby-lang.org/ja/man-1.6/?cmd=view;name=Module

In 1.6, the block parameter of Module.define_method is evaluated in
defining-time context (in this case, the self is Fixnum class object
rather than 3, the receiver object).
In 1.7 and later, the block is eval'ed with the receiver object
using instance_eval.


						FUKUMOTO Atsushi
						fukumoto / imasy.or.jp