Project

General

Profile

Actions

Backport #9238

closed

Monkey Patching Float class Infix Operators Produces Unexpected Result

Added by screenmutt (Dan Grahn) almost 11 years ago. Updated almost 11 years ago.


Description

Hello!

Patching Float class infix operators seem to work only if 2 are present. See the code below.

class Float
  def /(other)
    "magic"
  end
end

first_result = 10.0 / 2.0

class Float
  def *(other)
    "weird"
  end
end

second_result = 10.0 / 2.0

if first_result == 5.0 && second_result == "magic"
  puts "Bug confirmed"
else
  puts "Bug not present"
end

Related issues 1 (0 open1 closed)

Is duplicate of Ruby master - Bug #9237: Monkey Patching Infix Float Operator's Produces Unexpected ResultsClosed12/11/2013Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0