2009/1/21 Michael Heuer <heuermh@gmail.com>

Are you sure that doesn't work?  I swear I have been doing the same
with my collection classes.


I just tested it again to make absolutely sure.

objects.popBack() returns  "... :(void)" and

objects[count-1] returns something of type "object" so it seems like this is a popback issue more than something that is fundamentally impossible.

Below is a corrected version that does work and IMHO .popBack() can go on the bug list.

Yours,
Kas.

class Collection {
       Object objects[0];
       0 => int count;

       fun void add( Object obj ) {
               objects << obj;
               count++;
       }

       // this you can't do, apparently...
       fun Object pop() {
               objects[count-1] @=> Object s;
               count--;
               objects.size( objects.size()-1);
               return s;
       }
}

Collection myCollection;

SinOsc s;
Gain g;
Event e;

myCollection.add( s );
myCollection.add( g );
myCollection.add( e );

<<< myCollection.count >>>;

myCollection.pop() $ Event @=> Event f;

//make sure we can use it without crashing
f.signal();
<<< myCollection.count >>>;