Forum: Ruby-dev [ruby-trunk - Bug #7983][Open] Fixnumの演算子がprependでオーバーライドできない

Posted by tera (yuki teraoka) (Guest)
on 2013-02-28 05:00
(Received via mailing list)
Issue #7983 has been reported by tera (yuki teraoka).

----------------------------------------
Bug #7983: Fixnumの演算子がprependでオーバーライドできない
https://bugs.ruby-lang.org/issues/7983

Author: tera (yuki teraoka)
Status: Open
Priority: Normal
Assignee:
Category:
Target version:
ruby -v: ruby 2.0.0p0 (2013-02-24 revision 39474) [x86_64-linux]


=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
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.