Skip to content

Instantly share code, notes, and snippets.

@BrentonEarl
Created December 6, 2014 00:29
Show Gist options
  • Save BrentonEarl/c1688ca65afc53341f66 to your computer and use it in GitHub Desktop.
Save BrentonEarl/c1688ca65afc53341f66 to your computer and use it in GitHub Desktop.
Extends the string class to test if a string is an integer or if it is a float
class String
def is_float?
Float(self) != nil rescue false
end
def is_integer?
Integer(self) != nil rescue false
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment