title: How to split single line input in ruby and store it as different variable and different datatype (i.e Integer/String/Array)
body: <p>How to split single line input into multiple variable of different data type.</p>
  
  <h3>Example</h3>
  
  <pre><code>3 2 3 1  
  </code></pre>
  
  <h3>Sample Output</h3>
  
  <pre><code>n = 3               #Integer/FixNum
  a = [2,3,1]         #Array
  </code></pre>
  
  <h3>To be more specific, I need</h3>
  
  <p>To get 3(n) times the a(input) dynamically</p>
  
  <p><strong>like</strong>,</p>
  
  <pre><code>ip -&gt; 5 1 3 4 5 6
  op -&gt; n = 5 and a = [1,3,4,5,6]
  
  ip -&gt; 7 1 2 3 4 5 6 7
  op -&gt; n = 7 and a = [1,2,3,4,5,6,7]
  </code></pre>
  
  <hr>
  
  <h3>What I tried</h3>
  
  <pre><code>a,b = gets.split(" ").map(&amp;:to_i)  #it didn't not work
  
  op -&gt; a = 1, b = 2
  </code></pre>