Skip to content

Instantly share code, notes, and snippets.

@samknight
Created August 10, 2012 09:38
Show Gist options
  • Save samknight/3312973 to your computer and use it in GitHub Desktop.
Save samknight/3312973 to your computer and use it in GitHub Desktop.
Test a string is a valid number
# 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