check if string is integer ruby code example
Example 1: ruby test is number
12.is_a? Numeric
Example 2: ruby check if string is integer
class String
def numeric?
Float(self) != nil rescue false
end
end
"Hello World!".numeric?
12.is_a? Numeric
class String
def numeric?
Float(self) != nil rescue false
end
end
"Hello World!".numeric?