title: How to square each element of an array in Array class in Ruby?
body: <p>Part of my code is as follows:</p>
  
  <pre><code>class Array
    def square!
      self.map {|num| num ** 2}
      self
    end
  end
  </code></pre>
  
  <p>When I call:</p>
  
  <pre><code>[1,2,3].square!
  </code></pre>
  
  <p>I expect to get [1,4,9], but instead I get [1,2,3]. Why is this the case? When I call:</p>
  
  <pre><code>[1,2,3].map {|num| num ** 2}
  </code></pre>
  
  <p>outside of the class method, I get the correct answer.</p>