title: Checking if number is an integer in ruby using gets.chomp.to_i
body: <p>I am planning to check if a given input is an integer. <code>gets.chomp</code> gets input as a string, and I convert it into an integer using <code>to_i</code>. If I input <code>abcd</code> and check using <code>class</code> or <code>is_a(Integer)</code>, it always says it's an integer.</p>
  
  <pre><code>x = gets.chomp.to_i
  if x.is_a?(Integer)
      puts "It's an integer"
  else
      puts "It's a string"
  end
  </code></pre>
  
  <p>How can I check whether the input is an integer or a string?</p>