Last active
December 17, 2015 20:19
-
-
Save delba/5666507 to your computer and use it in GitHub Desktop.
Ruby refinements
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module FloatDivision | |
| refine Fixnum do | |
| def /(other) | |
| self.to_f / other | |
| end | |
| end | |
| end | |
| using FloatDivision | |
| class MathFun | |
| def self.ratio(a, b) | |
| a / b | |
| end | |
| end | |
| p MathFun.ratio(6, 8) #=> 0.75 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment