Issue #9237 has been updated by marcandre (Marc-Andre Lafortune).

Status changed from Open to Closed


----------------------------------------
Bug #9237: Monkey Patching Infix Float Operator's Produces Unexpected Results
https://bugs.ruby-lang.org/issues/9237#change-43587

Author: ChrisTimperley (Chris Timperley)
Status: Closed
Priority: Normal
Assignee: 
Category: 
Target version: 
ruby -v: ruby 2.0.0p353 (2013-11-22) [x64-mingw32]
Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN


=begin
Trying to redefine the infix division operator for the Float initially appears to have no effect.

    class Float
      def /(other)
        "magic!"
      end
     end
     puts 10.0/2.0
     # -> 5.0

But when another infix operator is added the infix division operator suddenly takes on the new definition!

    class Float
      def /(other)
        "magic!"
      end
      def *(other)
        "spooky"
      end
    end
    puts 10.0/2.0
    # -> "magic!"

These results were returned when these programs were run in isolation.

((*Ruby:*)) ruby 2.0.0p353 (2013-11-22) [x64-mingw32]

((*OS:*))  Windows 7 Home Premium SP1 (x64)
=end


-- 
http://bugs.ruby-lang.org/