Answers for "how to check if a variable is an integer in ruby"

1

ruby is int

1.is_a? Integer
=> true
"[email protected]".is_a? Integer
=> false
nil.is_a? Integer
=> false
Posted by: Guest on June-07-2020
-1

ruby check if string is integer

class String
  def numeric?
    Float(self) != nil rescue false
  end
end
"Hello World!".numeric?
Posted by: Guest on June-16-2020

Code answers related to "how to check if a variable is an integer in ruby"

Browse Popular Code Answers by Language