Project

General

Profile

This project is closed and read-only.

Actions

Backport #7983

closed

Fixnumの演算子がprependでオーバーライドできない

Backport #7983: Fixnumの演算子がprependでオーバーライドできない

Added by tera (yuki teraoka) over 13 years ago. Updated over 13 years ago.


Description

=begin
Fixnumの演算子をprependを使ってオーバーライドしても、適用されない。

sendで実行した場合はprependしたmoduleのメソッドが実行される。

【再現手順】

module M
def /(other)
to_f / other
end
end

Fixnum.send(:prepend, M)

1 / 2 #=> 0
1.send(:/, 2) #=> 0.5
=end

Actions

Also available in: PDF Atom