<p>I am using a multi-dimensional dynamic array in delphi and am trying to figure this out:</p>

<p>I have 2 seperate values for the first index and second index that are totally seperate of each other.</p>

<p>As new values come I want to grow the array if that new value is outside of either bound.</p>

<p>For new values x, y</p>

<p>I check:</p>

<pre><code>if Length(List) &lt; (x + 1) then
   SetLength(List, x + 1);
if Length(List[0]) &lt; (y + 1) then
   SetLength(List, Length(List), y + 1);
</code></pre>

<p>Is this the correct way to do this or is there a better way to grow the array as needed?</p>

It looks fine to me - if you change the last line to
```
```
SetLength(List, Length(List), y + 1);
```
```