title: ruby how read user input in scanf-style like in C++
body: <p>I am new in Ruby.
  I need to read from user input (n) numbers and in C++ i used this code</p>
  
  <pre><code>for(i=0;i&lt;N;i++)
  {
    scanf("%d",&amp;array[i]);
  }
  </code></pre>
  
  <p>this code read exactly (n) numbers separated by any white spaces (tabs, spaces, newlines).</p>
  
  <p>How i can do this in ruby?</p>
  
  <p>in Ruby I tried to do it like this </p>
  
  <pre><code>require 'scanf'
  n = scanf("%d");
  arr = Array.new()
  n.times { arr &lt;&lt; scanf("%d") }
  </code></pre>
  
  <p>but this code don't work when i intut string like this:</p>
  
  <pre><code>1   4    8
  </code></pre>
  
  <p>but works fine if i input this</p>
  
  <pre><code>1
  4
  8
  </code></pre>