Skip to content

Instantly share code, notes, and snippets.

@mrkn

mrkn/gist:8864745

Created Feb 7, 2014
Embed
What would you like to do?
module RefineInteger
refine Fixnum do
def /(other)
case other
when Integer
Rational(self, other)
else
super
end
end
end
end
module Rationalized
p 1 / 2 #=> 0
using RefineInteger
p 1 / 2 #=> (1/2)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.