title: How to check whether a string is an integer in Ruby?
body: <p>I have a string <code>"1234223"</code> and I want to check whether the value is an integer/number.</p>
  
  <p>How can I do that in one line?</p>
  
  <p>I have tried</p>
  
  <pre><code>1 =~ /^\d+$/ 
   =&gt; nil
  
  "1a" =~ /^\d+$/
   =&gt; nil
  </code></pre>
  
  <p>Both line are returning nil</p>