Actions
Bug #9237
closedMonkey Patching Infix Float Operator's Produces Unexpected Results
Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.0.0p353 (2013-11-22) [x64-mingw32]
Backport:
Description
=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
Updated by marcandre (Marc-Andre Lafortune) almost 11 years ago
- Status changed from Open to Closed
Actions
Like0
Like0