title: Override `[]=` method in ruby array
body: <p>I have a class <code>CustomArray</code>:</p>
  
  <pre><code>class CustomArray &lt; Array
    def initialize(row, col)
      @row = row
      @col = col
      @array ||= Array.new(size=row * col)
    end
  end
  </code></pre>
  
  <p>How can I override the <code>[]=</code> method of <code>CustomArray</code>? I did:</p>
  
  <pre><code>class CustomArray &lt; Array
    def []=(length, row, col)
      puts @array[0], col, row
    end
  end
  </code></pre>
  
  <p>Regardless of a change I make to <code>@array</code>, the new instantiated array length remains zero.</p>
  
  <p>I tried replacing the value of <code>self</code>, but it looks like <code>self</code> is read only.</p>