how to know if string is a number in ruby code example
Example: ruby check if string is integer
class String
def numeric?
Float(self) != nil rescue false
end
end
"Hello World!".numeric?
class String
def numeric?
Float(self) != nil rescue false
end
end
"Hello World!".numeric?