右から左に結合される演算子
たとえば、Rubyの+や*は左から右に結合されるけど、**は右から左に結合される。
class Fixnum alias :orig_add :+ def +( other ) ret = orig_add( other ) puts "#{self} + #{other} = #{ret}" return ret end alias :orig_mul :* def *( other ) ret = orig_mul( other ) puts "#{self} * #{other} = #{ret}" return ret end alias :orig_pow :** def **( other ) ret = orig_pow( other ) puts "#{self} ** #{other} = #{ret}" return ret end end p 1+2+3 p 1*2*3 p 1**2**3
1 + 2 = 3 3 + 3 = 6 6 1 * 2 = 2 2 * 3 = 6 6 2 ** 3 = 8 1 ** 8 = 1 1