title: Ruby map! function and nested array
body: <p>I need to find the distance between the 2nd and 3rd elements of each nested element so</p>
  
  <pre><code>nested_array = [[0, 3, 4], [1, 20, 21], [2, 2, 2]]
  
  def pythag_theorem(a, b)
      c = (a * a) + (b * b)
      result = Math.sqrt(c)
      result
  end
  
  def find_distance(array)
    t = 0
    while t &lt; array.length
      array[t].map! {|x| pythag_theorem(x[1], x[2])}
    t += 1
    end
  array
  end
  
  print find_distance(nested_array)
  </code></pre>
  
  <p>I'm getting</p>
  
  <pre><code>[[0.0, 1.4142135623730951, 0.0], [1.0, 0.0, 1.0], [1.0, 1.0, 1.0]]
  </code></pre>
  
  <p>when I need</p>
  
  <pre><code>[[0, 5], [1, 29], [2, 2.82842712474619]]
  </code></pre>
  
  <p>pythag_theorem works but why isn't map! working for me?  Thanks.</p>