title: Strictly convert string to integer (or nil)
body: <p>For web programming, numbers come in as strings. but <code>to_i</code> will convert <code>"5abc"</code> to <code>5</code> and <code>"abc"</code> to <code>0</code>, both wrong answers. To catch these, I wrote: </p>
  
  <pre><code>def number_or_nil( s )
    number = s.to_i
    number = nil if (number.to_s != s)
    return number
  end
  </code></pre>
  
  <p>Is there a neater, more Ruby-natural way of accomplishing this conversion and detecting that the string wasn't intended as a number?</p>