Hans;<br><br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

What is the difference exactly between .cap() and .size() ?<br>
</blockquote>
<br></div>
Don&#39;t know. I just needed array size, and started using size() :-).<div><br></div></blockquote><div><br>Working from memory;<br><br>In previous versions of ChucK .cap() could be used to get the length of the array, it could also (undocumentedly) be used to (re)set the length though at the expense of re-initialising all elements.<br>
<br>In 1.2.1.2 .size() was added which can be used exactly like .cap() to get the size of the array. It is overloaded to set the size, which should not re-initialise the existing elements (this works as far as I&#39;m aware) and which should initialise any new ones added (this does not always happen in practice). In the meantime .cap() is no longer overloaded to set array length.<br>
<br>Why this is like it is I don&#39;t know, in theory it might have broken some code, like how we could set all array elements of a array of type int to 0 while maintaining the same length using this;<br>foo.cap( foo.cap() );<br>
<br>more generally; using that we could re-initialise all elements without being aware of the type of the array. In practice I never heard about this resulting in any complaints. <br>
</div></div><br>The current situation, however, *is* a bit unclear (if much preferable to the old one). I can see how potentially breaking code would be preferable to dramatically changing it&#39;s functionality without warning but I&#39;m not sure that is the reasoning that led to the choices made.<br>
<br>Personally I use .cap() to get lengths and .size( int) to set them, purely for readability reasons.<br><br>Yours,<br>Kas.<br>