Skip to content

Instantly share code, notes, and snippets.

@mrkn
Created February 7, 2014 15:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrkn/8864745 to your computer and use it in GitHub Desktop.
Save mrkn/8864745 to your computer and use it in GitHub Desktop.
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