Created
August 10, 2012 09:38
-
-
Save samknight/3312973 to your computer and use it in GitHub Desktop.
Test a string is a valid number
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
# I couldn't find a nice way of working out whether a string is an integer other than using regex | |
# So here is another way of checking | |
number_string.to_i.to_s == number_string ? # integer : # not an integer |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment