title: Ruby: Reading integers from file and put them into array
body: <p>I have a file (<code>InputFile.txt</code>) containing blocks of integer numbers that each block is split using <code>*</code> character. Each block contains some rows that each row contains three integers, for example:</p>
  
  <blockquote>
    <p>4 1233 8</p>
    
    <p>2 55 11</p>
    
    <p>2 4 33 </p>
    
    <blockquote>
      <p>*</p>
    </blockquote>
    
    <p>3 5 34</p>
    
    <p>2 1 44 </p>
    
    <p>6 5 33</p>
    
    <blockquote>
      <p>*</p>
    </blockquote>
  </blockquote>
  
  <p>I want to read each block and put the integers in each block in a 2D array and do some processing on it. I found the following code:</p>
  
  <pre><code>f = File.read 'InputFile.txt'
  f.split('*').each  do |set|
    set.split.map(&amp;:to_i)
  </code></pre>
  
  <p>This code can read each block, But I don't know how to put each block in 2D array. I tried for example <code>set[0][0]</code> and it returns 4, but when I tried set[0][1] it returns blank space. Can anyone tell me what should I do? I want to see <code>1233</code> as the second number.</p>