Created
December 27, 2008 16:03
-
-
Save m0wfo/40271 to your computer and use it in GitHub Desktop.
This file contains 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
class Integer | |
def round_to_nearest(*args) | |
most = self % args[0] | |
most > (args[0]/2)? self - most + args[0] : self - most | |
end | |
end | |
anumber = 349 | |
p anumber.round_to_nearest(50) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment