Created
May 18, 2009 14:16
-
-
Save mwmitchell/113503 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
# number helper for limiting a number within a given range | |
class Fixnum | |
def limit(range) | |
return range.min if self < range.min | |
return range.max if self > range.max | |
self | |
end | |
end | |
puts true == (1 == -1998.limit(1..100)) | |
puts true == (100 == 1998.limit(1..100)) | |
puts true == (50 == 50.limit(1..100)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment