2009/1/21 Michael Heuer <span dir="ltr">&lt;<a href="mailto:heuermh@gmail.com">heuermh@gmail.com</a>&gt;</span><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 class="Ih2E3d"><br>
</div>Are you sure that doesn&#39;t work? &nbsp;I swear I have been doing the same<br>
with my collection classes.<br>
<br>
</blockquote><div><br>I just tested it again to make absolutely sure.<br><br>objects.popBack() returns&nbsp; &quot;... :(void)&quot; and <br><br>objects[count-1] returns something of type &quot;object&quot; so it seems like this is a popback issue more than something that is fundamentally impossible.<br>
</div></div><br>Below is a corrected version that does work and IMHO .popBack() can go on the bug list.<br><br>Yours,<br>Kas.<br><br>class Collection {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Object objects[0];<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0 =&gt; int count;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fun void add( Object obj ) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; objects &lt;&lt; obj;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; count++;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // this you can&#39;t do, apparently...<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fun Object pop() {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; objects[count-1] @=&gt; Object s;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; count--;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; objects.size( objects.size()-1);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return s;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>}<br><br>Collection myCollection;<br><br>SinOsc s;<br>Gain g;<br>Event e;<br><br>myCollection.add( s );<br>myCollection.add( g );<br>
myCollection.add( e );<br><br>&lt;&lt;&lt; myCollection.count &gt;&gt;&gt;;<br><br>myCollection.pop() $ Event @=&gt; Event f;<br><br>//make sure we can use it without crashing<br>f.signal();<br>&lt;&lt;&lt; myCollection.count &gt;&gt;&gt;;<br>